通过TextSwitcher实现广告栏内容动画切换
来源:互联网 发布:淘宝买家秀怎么点赞 编辑:程序博客网 时间:2024/05/13 22:10
textswitcher
1,布局中使用
<TextSwitcher android:id="@+id/switcher" android:layout_width="match_parent" //控制进入动画 根据需求自顶更改 android:inAnimation="@anim/enter_animation" //控制退出的动画 android:outAnimation="@anim/outer_animation" android:background="@color/cardview_dark_background" android:layout_height="wrap_content"> </TextSwitcher>
//动画 enter_animation
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="2000" android:fromYDelta="100%p" android:interpolator="@android:anim/accelerate_interpolator" android:toYDelta="0%p" /></set>
//退出动画 outer_animation
public class MainActivity extends FragmentActivity { int index; String [] str={"fahkfahkfha","窗前明月光"}; private Handler mHandler =new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); index++; mTextSwitcher.setText(str[index%2]); mHandler.sendEmptyMessageDelayed(0,2000); } }; private TextSwitcher mTextSwitcher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextSwitcher = (TextSwitcher) findViewById(R.id.switcher); mTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView textView=new TextView(MainActivity.this); FrameLayout.LayoutParams layoutParams= new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); textView.setPadding(0,40,0,40); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setLayoutParams(layoutParams); return textView; } }); mTextSwitcher.setText("hahahha"); mHandler.sendEmptyMessageDelayed(0,2000); }
0 0
- 通过TextSwitcher实现广告栏内容动画切换
- 用TextSwitcher实现文字切换动画
- TextSwitcher切换动画
- Hack 5 用TextSwitcher实现文字切换动画
- Hack 5 用TextSwitcher实现文字切换动画
- 使用textswitcher进行切换动画
- 通过TextSwitcher实现上下滚动的广告动画效果
- TextSwitcher滑动动画改变内容
- TextSwitcher类(TextView改变文本动画切换)
- ImageSwitcher,TextSwitcher实现图片,文字切换
- 广告栏实现
- (Android)自动切换的ViewPager广告栏(带动画和切换速率控制)
- TextSwitcher--文本切换器
- TextSwitcher,ImageSwitcher切换器
- 仿知乎内容广告栏 WindowImageView
- TextSwitcher,一个带有文字切换动画效果的加强版TextView
- 通过单选钮切换显示内容
- Android TextSwitcher - 文本切换器
- 如何很燃地解决问题
- android Hid 实现注意事项
- php中的 header () 函数详解
- AngularJS在实际项目中的应用系列目录
- 汉诺塔算法--java版
- 通过TextSwitcher实现广告栏内容动画切换
- R柱状图,叠图(排序)
- DOS/BAT批处理if exist else 语句的几种用法
- 32、Power Query-利用自定义函数获取指定页数数据
- Linux中如何添加自己的路径为全局路径
- SSL 2601 网络流——飞行员配对问题
- 刘凯stm32教程第11讲总结
- 【SIP基础】SIP协议中网络角色定义
- c语言指针