Android:TextSwitcher、imageSwitcher
2013-06-20 21:51
435 查看
TextSwitcher只能放两个textview控件。
主要属性设置:
XML代码如下:
启动动画,java代码如下:
imageSwitcher同理:
主要属性设置:
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);
相关文章推荐
- android的ImageSwitcher和TextSwitcher
- Android_TextSwitcher和ImageSwitcher
- Android学习之路---ImageSwitcher和TextSwitcher切换图片及文本
- Android UI基础——TextSwitcher&ImageSwitcher控件
- android:为TextView添加样式、跑马灯、TextSwitcher和ImageSwitcher实现平滑过渡
- Android_TextSwitcher和ImageSwitcher
- Android仿淘宝商品自动滚动 ImageSwitcher和TextSwitcher的用法
- Android控件之ImageSwitcher_图片切换和TextSwitcher_文字切换
- 系出名门Android(8) - 控件(View)之TextSwitcher, Gallery, ImageSwitcher, GridView, ListView, ExpandableList
- 二、Android应用的界面编程(七)ViewAnimator及其子类[ ViewSwitcher、ImageSwitcher、TextSwitcher、ViewFlipper ]
- Android零基础入门第55节:ImageSwitcher和TextSwitcher使用
- android TextSwitcher
- 【Android开发】TextSwitcher 使用详解
- Android中ImageSwitcher报NullPointerException,但ImageSwitcher中有值.解决办法如下
- android 开发技巧(5)--使 用 TextSwitcher 实现平滑过渡
- <转>Android 中文 API (17) —— TextSwitcher
- Android TextSwitcher官方使用教程
- 安卓滚动字幕以及TextSwitcher、ImageSwitcher使用
- Android UI之ImageSwitcher && TextSwitcher 实现图文翻页
- 玩转Android---组件篇---TextSwitcher