Android动画之图片动画
2015-07-02 15:07
627 查看
现在使ImageView中的图片可以动起来
1.在drawable-mdpi文件夹下加入图片,并加入一个xml文件,文件如下
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/a" android:duration="500"/>
<item android:drawable="@drawable/b" android:duration="500"/>
<item android:drawable="@drawable/c" android:duration="500"/>
<item android:drawable="@drawable/d" android:duration="500"/>
</animation-list>
2.代码如下
[java] view
plaincopy
iv.setBackgroundResource(R.drawable.anim);
AnimationDrawable an=(AnimationDrawable)iv.getBackground();
an.start();
其实可以用一个线程加Handler来实现动画的,在线程中隔一定时间发送消息,更改ImageView的图片
1.在drawable-mdpi文件夹下加入图片,并加入一个xml文件,文件如下
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/a" android:duration="500"/>
<item android:drawable="@drawable/b" android:duration="500"/>
<item android:drawable="@drawable/c" android:duration="500"/>
<item android:drawable="@drawable/d" android:duration="500"/>
</animation-list>
2.代码如下
[java] view
plaincopy
iv.setBackgroundResource(R.drawable.anim);
AnimationDrawable an=(AnimationDrawable)iv.getBackground();
an.start();
其实可以用一个线程加Handler来实现动画的,在线程中隔一定时间发送消息,更改ImageView的图片
相关文章推荐
- android 实用代码
- Android动画之Interpolator和AnimationSet
- android属性动画—自己的测试代码
- android动画之一Tween动画
- Android Studio创建库项目及引用
- 基于android平台开发的计算器
- Android 自定义回调
- Android 基于位置的服务(LBS)
- Android打包常见错误之Export aborted because fatal lint errors were found
- 基于android平台开发的计算器
- [Android]Intent 实现页面跳转的方式[转]
- Android Studio中文乱码的解决
- android模拟按键
- [android警告]AndroidManifest.xml警告 Not targeting the latest versions of Android
- android的Broadcast receiver
- 调用系统相机导致照片旋转问题的修复
- Android studio 启动另一个activity
- ContentObserver 介绍
- 【Android基础篇】TabWidget设置背景和字体
- Android版本和API Level对应关系