目标:实现界面淡入效果
在res下新建anim文件夹,定义list_anim.xml文件
<?xml version="1.0" encoding="utf-8"?>
<!-- 处理listview淡入淡出的xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="1000" />
</set>
定义list_animation_layout.xml文件
<?xml version="1.0" encoding="utf-8"?>
<!-- 设置淡入淡出的时间间隔,以及出现的顺序——随机 -->
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="0.2" android:animationOrder="random" android:animation="@anim/list_anim" />
修改activity_study.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"
android:background="@drawable/bg_ling" >
<ListView
android:id="@id/android:list"
android:layoutAnimation="@anim/list_animation_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
</RelativeLayout>