帧动画
2016-06-14 16:10
92 查看
动画anima.xml文件(在drawable目录下):
oneshot表示执行次数,当为false时则表示只执行一次,当为true时表示循环执行
布局文件:
java代码:
oneshot表示执行次数,当为false时则表示只执行一次,当为true时表示循环执行
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/pic_1 android:duration="200"/> <item android:drawable="@drawable/pic_2 android:duration="200"/> <item android:drawable="@drawable/pic_3 android:duration="200"/> <item android:drawable="@drawable/pic_4 android:duration="200"/> </animation>
布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/iv_test" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
java代码:
...code.. ImageView ivTest = (ImageView)findViewById(R.id.iv_test); ivTest.setBackgroundResource(R.drawable.anima); AnimationDrawable ad = (AnimationDrawable)ivTest.getBackground();//获取帧动画对象 ad.start(); ....code...
相关文章推荐
- Windows程序安装包制作——EasySetup
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- iOS YSAuth 第三方登录及分享
- 集成极光推送服务,实现通知推送功能
- 阶乘的长度
- Educational Codeforces Round 13-D. Iterated Linear Function
- 高通QSD MSM APQ区别
- 关于用sea.js时碰到的坑
- VS编译QT程序调用SQLite数据库研究
- swift开发基础
- Url解析类
- mysql语句优化
- find
- 高通QSD MSM APQ区别
- Apache Kafka:下一代分布式消息系统
- Android WebView 拦截自定义协议
- 序列化Serializable serialVersionUID的作用
- 从0开始学习 GitHub 系列之「向GitHub 提交代码」
- mysql给root开启远程访问权限,修改root密码
- 257.BinaryTreePaths