天天看點

android ListView增加Animation效果

anim檔案夾下建立anim_layout.xml和alpha.xml

-----------------------android:animationorder 的取值有normal

0 預設reverse 1 倒序random 2 随機-----------------------

anim_layout.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="random"  

 android:animation="@anim/alpha"  

 />  

alpha.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"  

        android:interpolator="@android:anim/accelerate_interpolator">  

    <alpha  

        android:fromalpha="0.0"  

        android:toalpha="1.0"  

        android:duration="500" />  

</set>  

布局檔案裡的listview增加一個layoutanimation屬性

[java] view

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"  

    android:layout_width="fill_parent"  

    android:layout_height="fill_parent"  

    android:orientation="vertical" >  

    <listview   

        android:id="@id/android:list"  

        android:layout_width="fill_parent"  

        android:layout_height="fill_parent"  

        android:drawselectorontop="false"  

        android:layoutanimation="@anim/anim_layout"  

        ></listview>  

    <textview  

        android:id="@id/android:empty"  

        android:text="no data" />  

</linearlayout>  

繼續閱讀