Android-AnimationDrawable(二)

时间:2015-01-26 10:02:49   收藏:0   阅读:319

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

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false" >

    <item
        android:drawable="@drawable/on_001"
        android:duration="100"/>

    <item
        android:drawable="@drawable/on_002"
        android:duration="100"/>

    <item
        android:drawable="@drawable/on_003"
        android:duration="100"/>

    <item
        android:drawable="@drawable/on_004"
        android:duration="100"/>

    <item
        android:drawable="@drawable/on_005"
        android:duration="100"/>

    <item
        android:drawable="@drawable/on_006"
        android:duration="100"/>
</animation-list>

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

    AnimationDrawable ad = (AnimationDrawable) getResources().getDrawable(
        R.drawable.bootanimation);
    mView.setBackgroundDrawable(ad);
    ad.start();

本文转自:http://www.cnblogs.com/janken/archive/2012/07/20/2601226.html

原文:http://www.cnblogs.com/sishuiliuyun/p/4249463.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!