您的位置:首页 > 移动开发 > Android开发

Android开发之Frame动画实现方法

2014-06-27 15:17 555 查看
1, 在该工程的res/anim/目录下创建一个XML动画文件,代码animation.xml 如所示

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"

         android:oneshot="true">

         <item android:drawable="@drawable/p01" android:duration="500"/>

         <item android:drawable="@drawable/p02" android:duration="500"/>

             .....

  </animation-list>         

2,显示界面布局文件添加 ImageView空件来显示动画

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

         android:orientation="vertical"

         android:layout_width="fill_parent"

         android:layout_height="fill_parent"

        >

        <ImageView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:background="@anim/animation"

            android:id="@+id/ImageView01"></ImageView>

    </LinearLayout>       

3,在对应的Activity中实例花AnimationDrawable对象

   private AnimationDrawable animationDrawable= imageView.getBackground();

   animationDrawable.start();开始动画

   animationDrawable.stop();结束动画
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: