From colleagues_Smile's packaging application, record and learn, and share it with everyone, as follows:
1. Encapsulation of AnimImageViewLoader class
/** * Applicable to animation-list animation * Created by _Smile on 2016/6/13. */ public class AnimImageViewLoader extends ImageView { private AnimationDrawable frameAnimation; public AnimImageViewLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } public AnimImageViewLoader(Context context, AttributeSet attrs) { super(context, attrs); init(); } public AnimImageViewLoader(Context context) { super(context); init(); } /** * Initialize animation information */ private void init() { frameAnimation = (AnimationDrawable) getBackground(); post(new Runnable(){ public void run(){ (); } }); } /** * Start the startup display */ public void startAnimation() { frameAnimation = (AnimationDrawable) getBackground(); post(new Runnable() { @Override public void run() { (); } }); } /** * Close animation display */ public void stopAnimation() { post(new Runnable() { @Override public void run() { (); } }); } }
2. Layout files
< android: style="@style/style_wrap_content" android:layout_alignTop="@id/iv_id_card_take_pic_main" android:background="@drawable/anim_id_card_positive_pic" />
3. Calls in the code
AnimImageViewLoader aivIdCardPic = xFindViewById(.aiv_take_id_card_pic); (.anim_id_card_negative_pic); ();
4. .anim_id_card_negative_pic file content
<?xml version="1.0" encoding="utf-8"?> <!--Picture animation--> <animation-list xmlns:andro> <item android:drawable="@mipmap/ic_id_card_negative_01" android:duration="300"/> <item android:drawable="@mipmap/ic_id_card_negative_02" android:duration="300"/> <item android:drawable="@mipmap/ic_id_card_negative_03" android:duration="300"/> <item android:drawable="@mipmap/ic_id_card_negative_04" android:duration="300"/> <item android:drawable="@mipmap/ic_id_card_negative_05" android:duration="300"/> <item android:drawable="@mipmap/ic_id_card_negative_06" android:duration="300"/> </animation-list>
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.