Android-帧动画
来源:互联网 发布:淘宝营销系统架构 编辑:程序博客网 时间:2024/06/07 05:24
Android-帧动画
一 帧动画
又叫做Drawable Animation,就是不同对象之间过渡事件比较快形成的动画,也是动画片的原理
二 话不多说,看Demo
下面例子是实现4张图片的切换动画效果,比较简单
1,在drawable中定义4张图片的xml以及过渡时间
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@drawable/gesture1" android:duration="200"></item> <item android:drawable="@drawable/gesture2" android:duration="200"></item> <item android:drawable="@drawable/gesture3" android:duration="200"></item></animation-list>
2,定义显示图片的layout布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/buttonAnimList" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Ok" /></LinearLayout>
3,定义主Activity类
public class MyAnimationListActivity extends Activity{ private AnimationDrawable mAnimationDrawable; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); //设置布局文件 setContentView(R.layout.my_animlist_layout); //得到布局的ImageView对象 ImageView _imageView = (ImageView)findViewById(R.id.imageView); //得到ImageView的背景 _imageView.setBackgroundResource(R.drawable.my_anim_list); //利用AnimationDrawable来完成帧动画 mAnimationDrawable = (AnimationDrawable)_imageView.getBackground(); //得到按钮对象 Button _buttonList = (Button)findViewById(R.id.buttonAnimList); //设置点击事件 _buttonList.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub //动画只播放一次,设置为true mAnimationDrawable.setOneShot(true); //动画开始 mAnimationDrawable.start(); } }); }}
运行程序,点击按钮,图片相互切换,且只播放一次
0 0
- Android动画-帧动画
- Android动画--帧动画
- android动画 -- 帧动画 补间动画
- Android动画-帧动画&补间动画
- Android加载动画 旋转动画 、帧动画
- Android动画-帧动画-属性动画
- Android动画_帧动画
- android-帧动画、布局动画
- Android动画一:帧动画
- Android帧动画(WiFi动画)
- Android动画 - AnimationDrawable帧动画
- Android动画之---帧动画
- Android动画(二):帧动画
- Android 动画总结-帧动画
- Android 动画之帧动画
- Android动画之帧动画
- android动画_帧动画
- android 动画 帧动画 FrameAnimation
- 为什么要使用R语言?历数R的优势与缺点
- 第一篇博客
- C语言之基本算法28—硬币抛投(随机数)
- Centos版本 32或64位查看命令
- Oracle创建序列
- Android-帧动画
- [小技巧] Linux 下查询图片的大小
- Silverlight 5 Grid组的MouseLeave响应
- 黑马程序员——JAVA基础---操作数组
- 【最短路】hdu2544 SPFA以及SPFA的优化
- open函数和fopen函数的区别
- 探索C++的秘密之详解extern
- SHELL正则表达式介绍
- 事件分发机制