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();
  • 相关阅读:
    标准输入输出
    UNIX基础概念
    phpstrom设置php环境
    nginx+php+swoole安装记录
    MySQL索引
    生成器来解决大文件读取,大数据下载
    PHP调优
    PHP-FPM详解
    远程登录服务器配置
    HTTPS配置
  • 原文地址:https://www.cnblogs.com/janken/p/2601226.html
Copyright © 2011-2022 走看看