1、先写出需要的动画效果list_anim.xml
<?xml version="1.0" encoding= "utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- android:duration="1500" 动画持续时间 -->
<!-- android:fillAfter="true" 动画结束时停留在结束位置 -->
<!-- android:fromAlpha="0.0" 动画起始透明度:透明 -->
<!-- android:toAlpha="1.0" 动画结束透明度:显示 -->
<alpha
android:duration="2000"
android:fillAfter="true"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
2、写出动画加载文件gridview_anim.xml
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/list_anim"
android:animationOrder="normal"
android:delay="0.5" />
3、在GridView的布局中配置动画activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="hjk.anim.grid.MainActivity" >
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3"
android:cacheColorHint="@android:color/transparent"
android:drawSelectorOnTop="false"
android:fadingEdgeLength="0.0dp"
android:layoutAnimation="@anim/gridview_anim"
android:listSelector="#ffffff" />
</RelativeLayout>