zoukankan      html  css  js  c++  java
  • Android中的AnimationDrawable的使用

    首先可以先定义一个逐帧播放的xml:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:oneshot="false" >
     4 
     5     <item
     6         android:drawable="@drawable/on_001"
     7         android:duration="100"/>
     8 
     9     <item
    10         android:drawable="@drawable/on_002"
    11         android:duration="100"/>
    12 
    13     <item
    14         android:drawable="@drawable/on_003"
    15         android:duration="100"/>
    16 
    17     <item
    18         android:drawable="@drawable/on_004"
    19         android:duration="100"/>
    20 
    21     <item
    22         android:drawable="@drawable/on_005"
    23         android:duration="100"/>
    24 
    25     <item
    26         android:drawable="@drawable/on_006"
    27         android:duration="100"/>
    28 </animation-list>

    然后在代码中定义出AnimationDrawable对象,并设置到view的background上,然后设置开始播放就可以了:

    1         AnimationDrawable ad = (AnimationDrawable) getResources().getDrawable(
    2                 R.drawable.bootanimation);
    3         mView.setBackgroundDrawable(ad);
    4         ad.start();
  • 相关阅读:
    POJ 2251 Dungeon Master
    HDU 3085 Nightmare Ⅱ
    CodeForces 1060 B Maximum Sum of Digits
    HDU 1166 敌兵布阵(树状数组)
    HDOJ 2050 折线分割平面
    HDU 5879 Cure
    HDU 1878 欧拉回路
    HDU 6225 Little Boxes
    ZOJ 2971 Give Me the Number
    HDU 2680 Choose the best route
  • 原文地址:https://www.cnblogs.com/janken/p/2601226.html
Copyright © 2011-2022 走看看