TextSwitcher只能放两个textview控件。

主要属性设置:

android:inAnimation="@anim/setanimin"android:outAnimation="@anim/setanimout"


XML代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity" >    <TextSwitcher        android:id="@+id/textSwitcher1"        android:layout_width="match_parent"        android:layout_height="120dp"        android:inAnimation="@anim/setanimin"        android:outAnimation="@anim/setanimout"        android:layout_alignParentLeft="true"        android:layout_alignParentTop="true" >        <TextView            android:id="@+id/textView2"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="Large Text"            android:textAppearance="?android:attr/textAppearanceLarge" />        <TextView            android:id="@+id/textView1"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="Large Text"            android:textAppearance="?android:attr/textAppearanceLarge" />    </TextSwitcher></RelativeLayout>


启动动画,java代码如下:

textSwitcher = (TextSwitcher) findViewById(R.id.textSwitcher1);action = new Runnable(){    @Override    public void run()    {        num++;        textSwitcher.setText(ss[ num % ss.length] );//通过setText启动动画        textSwitcher.postDelayed(action , 1000);    }};textSwitcher.postDelayed(action , 1000);



imageSwitcher同理:

imageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher1);        action = new Runnable()        {            @Override            public void run()            {                num++;                imageSwitcher.setImageResource(mPhoto[num % 6]);                imageSwitcher.postDelayed(action , 5000);            }        };        imageSwitcher.postDelayed(action , 100);








本文出自 “天空没有痕迹但我飞过” 博客,转载请与作者联系!

更多相关文章

  1. 【Arcgis android】 离线编辑实现及一些代码段
  2. Android弹性动画三种实现方式
  3. Android 实现扫雷小游戏实例代码
  4. android代码分析,及Terminal使用
  5. Android应用程序绑定服务(bindService)的过程源代码分析(2)
  6. android中四个典型动画设置
  7. [导入]Android代码优化
  8. android APP隐私政策弹框的实现代码实例
  9. android手机打电话代码分析

随机推荐

  1. php常用函数练习
  2. 解构赋值 、函数参数中使用解构的方式、
  3. 分析ThinkORM新增加的虚拟模型功能
  4. 招聘h5页面是什么?意派Epub360老司机带你
  5. PHP 【环境;变量;数据类型】
  6. 实现一个简单的计算器功能
  7. python数字怎么转对应中文
  8. php一招搞定替换指定字符(大小写不敏感)
  9. 详细介绍php替换指定字符的方法(大小写敏
  10. PHP开发实例之公共方法【代码详解】