anim文件夹下建立anim_layout.xml和alpha.xml

-----------------------android:animationOrder 的取值有normal 0 默认reverse 1 倒序random 2 随机-----------------------

anim_layout.xml


[html] 
​​view plain​​​
​​​copy​​
1. <?xml version="1.0" encoding="utf-8"?>
2. <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
3.
4. android:delay="0.5"
5. android:animationOrder="random"
6. android:animation="@anim/alpha"
7. />



alpha.xml


[html] 
​​view plain​​​
​​​copy​​

1. <?xml version="1.0" encoding="utf-8"?>
2. <set xmlns:android="http://schemas.android.com/apk/res/android"
3. android:interpolator="@android:anim/accelerate_interpolator">
4.
5. <alpha
6. android:fromAlpha="0.0"
7. android:toAlpha="1.0"
8. android:duration="500" />
9.
10. </set>



布局文件里的ListView增加一个layoutAnimation属性


[java] 
​​view plain​​​
​​​copy​​

1. <?xml version="1.0" encoding="utf-8"?>
2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3. "fill_parent"
4. "fill_parent"
5. "vertical" >
6.
7. <ListView
8. "@id/android:list"
9. "fill_parent"
10. "fill_parent"
11. "false"
12. "@anim/anim_layout"
13. ></ListView>
14.
15. <TextView
16. "@id/android:empty"
17. "fill_parent"
18. "fill_parent"
19. "No data" />
20.
21. </LinearLayout>