首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android Frame Animation帧卡通实现方法

2012-08-09 
Android Frame Animation帧动画实现方法Frame Animation实现方法:定义在一XML文件,比如res/anim/anim_exam

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();

热点排行