帧动画的使用很简单,首先在Drawable中定义如下xml
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@mipmap/img_1" android:duration="500"/> <item android:drawable="@mipmap/img_2" android:duration="500"/> <item android:drawable="@mipmap/img_3" android:duration="500"/> </animation-list>然后使用的方法:
//将上面定义的Drawable作为View的背景,并通过Drawable来播放即可 btn_animView.setBackgroundResource(R.drawable.frame_animation); AnimationDrawable drawable = (AnimationDrawable)btn_animView.getBackground(); drawable.start();