发布于 2017-06-20 09:34:17 | 202 次阅读 | 评论: 0 | 来源: 网友投递
Android移动端操作系统
Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。
tvNotice = (TextSwitcher)rootView.findViewById(R.id.tv_notice);
tvNotice.setFactory(new ViewSwitcher.ViewFactory() {
//这里 用来创建内部的视图,这里创建TextView,用来显示文字
public View makeView() {
TextView tv =new TextView(getContext());
//设置文字大小
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX,getResources().getDimension(R.dimen.group_notice_font_size));
//设置文字 颜色
tv.setTextColor(getResources().getColor(R.color.font_333333));
return tv;
}
});
然后自己可用timer或者Thread去控制轮播,轮播中控制tvNotice的代码如下
// 设置切入动画
tvNotice.setInAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_bottom));
// 设置切出动画
tvNotice.setOutAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_out_up));
//items是一个字符串列表,index就是动态的要显示的items中的索引
tvNotice.setText(itmes.get(index).getTitle());
slide_in_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:shareInterpolator="false" android:zAdjustment="top"
>
<translate
android:duration="1000"
android:fromYDelta="100%p"
android:toYDelta="0" />
</set>
slide_out_up.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:shareInterpolator="false" android:zAdjustment="top"
>
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="-100%p" />
</set>
以上所述是小编给大家介绍的Android TextSwitcher实现文字上下翻牌效果(铜板街),希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的,在此也非常感谢大家对PHPERZ网站的支持!