Android动画之LayoutAnimationController
2015-07-02 16:21
423 查看
LayoutAnimationController可以控制一组控件按照规定显示,有两种方法来实现
1.下面以XML文件实现,先在res下新建anim文件夹,新建一个文件alpha.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true"
>
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="3000"
/>
</set>
然后新建一个文件layoutanimation.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="0.5"
android:animationOrder="normal"
android:animation="@anim/alpha"
/>
在listview中使用下面代码
[html] view
plaincopy
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layoutanimation"/>
这样就完成了
2.代码实现
[java] view
plaincopy
AlphaAnimation alpha=new AlphaAnimation(0, 1);
alpha.setDuration(3000);
LayoutAnimationController lac=new LayoutAnimationController(alpha);
lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
lv.setLayoutAnimation(lac);
下面是显示的顺序
LayoutAnimationController.ORDER_NORMAL; //顺序显示
LayoutAnimationController.ORDER_REVERSE;//反显示
LayoutAnimationController.ORDER_RANDOM//随机显示
1.下面以XML文件实现,先在res下新建anim文件夹,新建一个文件alpha.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true"
>
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="3000"
/>
</set>
然后新建一个文件layoutanimation.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="0.5"
android:animationOrder="normal"
android:animation="@anim/alpha"
/>
在listview中使用下面代码
[html] view
plaincopy
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layoutanimation"/>
这样就完成了
2.代码实现
[java] view
plaincopy
AlphaAnimation alpha=new AlphaAnimation(0, 1);
alpha.setDuration(3000);
LayoutAnimationController lac=new LayoutAnimationController(alpha);
lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
lv.setLayoutAnimation(lac);
下面是显示的顺序
LayoutAnimationController.ORDER_NORMAL; //顺序显示
LayoutAnimationController.ORDER_REVERSE;//反显示
LayoutAnimationController.ORDER_RANDOM//随机显示
相关文章推荐
- Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
- Android 虚拟按键驱动实现
- Android.mk添加第三方jar包
- Android Studio开发入门-引用jar及so文件
- Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPoi
- Android studio 閿欒 : 缂栫爜UTF-8鐨勪笉鍙 槧灏勫瓧绗?
- Android知识点
- Android 沉浸式状态栏效果(状态栏与内容完全融合、类似于iphone 7.0系统)
- Android NFC APDU
- android Notification .
- Android监听Home键按下
- 从setContentView方法分析Android加载布局流程
- Android Activity的onSaveInstanceState() 和 onRestoreInstanceState()方法
- ConcurrentHashMap类的理解
- android Activity的生命周期
- android4.0触摸屏(touchscreen)以及屏幕按键驱动解析
- 如何使用Android Studio把自己的Android library分享到jCenter和Maven Central
- Android多任务断点下载
- Android:Layout_weight的理解
- android GPS度分秒与double之间的相互转化