什麼是LayoutAnimationControler:
1,用於爲一個layout裏面的控件或者ViewGroup裏面的控件設置動畫效果。
2,每一個控件都有相同的動畫效果。
3,這些控件的動畫在不同時間顯示出來。
4,LayoutAnimationControler可以在xml中設置,也可以在代碼中設置。
1. LayoutAnimationController用於爲一個Layout裏面的控件或者是Viewgroup的控件設置動畫效果。。
2.每一個控件都會有相同的動畫效果
3.這些動畫效果在不同的時間現實出來
4.LayoutAnimationController不僅可以在Layout裏面實現也可以在代碼中實現。。
怎麼樣在xml中使用LayoutAnimationController:
1在res/anim文件夾中創建一個新文件名爲list-item-layout.xml文件
?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="2"
android:animationOrder="normal"
android:animation="@anim/list_anim" />
2在佈局文件當中添加如下配置
android:layoutAnimation=“@anim/list_item_layout”
在代碼中使用LayoutAnimationController
1.創建一個Animation對象,可以通過裝載xml文件 也可以通過構造函數構造對象
2.使用如下代碼創建LayoutAnimationController
LayoutAnimationController lac=new LayoutAnimationController(animation);
3.設置控件顯示的順序
lrc.setOrder(LayoutAnimationController.ORDER_NORMAL)
4.爲ListView設置LayoutAnimationController屬性
listview.setLayoutAnimation(lac);
Animation animation = (Animation)AnimationUtils.loadAnimation(MainActivity.this, R.anim.list_anim);
LayoutAnimationController lac = new LayoutAnimationController(animation);
lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
lac.setDelay(0.5f);
listView.setLayoutAnimation(lac)