当前位置: 移动技术网 > IT编程>移动开发>Android > Android TextSwitcher实现文字上下翻牌效果(铜板街)

Android TextSwitcher实现文字上下翻牌效果(铜板街)

2019年07月24日  | 移动技术网IT编程  | 我要评论

常熟旅游网,疤顿,中大行以房养老的骗局

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实现文字上下翻牌效果(铜板街),希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网