读书人

Android Frame Animation帧卡通实现方

发布时间: 2012-08-09 15:59:21 作者: rapoo

Android Frame Animation帧动画实现方法

Frame Animation实现方法:

定义在一XML文件,比如res/anim/anim_example.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/pic01" android:duration="200" />
??????????? <item android:drawable="@drawable/pic02" android:duration="200" />
??????????? <item android:drawable="@drawable/pic03" android:duration="200" />
??????? </animation-list>

代码:

??????? ImageView someView = (ImageView) findViewById(R.id.some_view);
??????? someView.setBackgroundResource(R.drawable.anim_example);

??????? AnimationDrawable? someAnimation = (AnimationDrawable) someView.getBackground();
??????? //开始播放动画
??????? someAnimation .start();
??????? //停止播放动画
??????? someAnimation .stop();

读书人网 >Android

热点推荐