逐帧动画与传统的卡通相似,也有点像gif。就是搞几张图片,根据顺序显示。
AnimationDrawable类可以用来创建一个新的表示为一个Drawable资源的逐帧动画,可以使用XML,在应用程序的res/drawable文件夹下讲动画Drawable资源定义为外部资源。
下面看程序和效果:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:drawable="@drawable/h1" android:duration="500" />
<item android:drawable="@drawable/h2" android:duration="500" />
<item android:drawable="@drawable/h3" android:duration="500" />
<item android:drawable="@drawable/h4" android:duration="500" />
</animation-list>
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/line_gradient"
/>
</RelativeLayout>
由于CSDN不知道咋上传动态图,所以,,,就不上传了。各位自己实验吧。。