国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

詳解android 中animation-list 動畫的應用

2019-12-12 01:22:25
字體:
來源:轉載
供稿:網(wǎng)友

來自同事_Smile的封裝應用,記錄學習一下,分享給大家,具體如下:

1、AnimImageViewLoader類的封裝

/** * 適用于animation-list 動畫 * 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();  }  /**   * 初始化動畫信息   */  private void init() {    frameAnimation = (AnimationDrawable) getBackground();    post(new Runnable(){      public void run(){        frameAnimation.start();      }    });  }  /**   * 開啟動畫顯示   */  public void startAnimation() {    frameAnimation = (AnimationDrawable) getBackground();    post(new Runnable() {      @Override      public void run() {        frameAnimation.start();      }    });  }  /**   * 關閉動畫顯示   */  public void stopAnimation() {    post(new Runnable() {      @Override      public void run() {        frameAnimation.stop();      }    });  }}

2、布局文件

<com.tecsun.tsb.res.widget.AnimImageViewLoader        android:id="@+id/aiv_take_id_card_pic"        style="@style/style_wrap_content"        android:layout_alignTop="@id/iv_id_card_take_pic_main"        android:background="@drawable/anim_id_card_positive_pic" />

3、在代碼中的調用

AnimImageViewLoader aivIdCardPic = xFindViewById(R.id.aiv_take_id_card_pic); aivIdCardPic.setBackgroundResource(R.drawable.anim_id_card_negative_pic); aivIdCardPic.startAnimation();

4、R.drawable.anim_id_card_negative_pic文件內容

<?xml version="1.0" encoding="utf-8"?><!--圖片動畫--><animation-list xmlns:android="http://schemas.android.com/apk/res/android">  <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>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 罗田县| 永宁县| 成武县| 仙桃市| 鄱阳县| 广西| 怀仁县| 界首市| 饶河县| 安达市| 延川县| 金山区| 郯城县| 宜君县| 洛南县| 玛沁县| 萨迦县| 手游| 射阳县| 襄汾县| 遂川县| 思南县| 丰城市| 吉木萨尔县| 东阳市| 镇康县| 莆田市| 华亭县| 盐边县| 阳曲县| 兴宁市| 安国市| 志丹县| 分宜县| 武宣县| 遂平县| 祁连县| 恩施市| 肇东市| 惠东县| 鹿泉市|