展会信息港展会大全

Android动画之LayoutAnimationController(五)
来源:互联网   发布日期:2015-10-13 15:31:45   浏览:2137次  

导读:LayoutAnimationController可以控制一组控件按照规定显示,有两种方法来实现1.下面以XML文件实现,先在res下新建anim文件夹,新建一个文件alpha.xml[h...

LayoutAnimationController可以控制一组控件按照规定显示,有两种方法来实现

1.下面以XML文件实现,先在res下新建anim文件夹,新建一个文件alpha.xml

[html]

<?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>

<?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]

<?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"

/>

<?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]

<ListView

android:id="@+id/listView1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layoutAnimation="@anim/layoutanimation"/>

<ListView

android:id="@+id/listView1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layoutAnimation="@anim/layoutanimation"/>

这样就完成了

2.代码实现

[java]

AlphaAnimation alpha=new AlphaAnimation(0, 1);

alpha.setDuration(3000);

LayoutAnimationController lac=new LayoutAnimationController(alpha);

lac.setOrder(LayoutAnimationController.ORDER_NORMAL);

lv.setLayoutAnimation(lac);

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开发 教程

相关内容
AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港