帧动画
来源:互联网 发布:特拉亨伯格数学计算法 编辑:程序博客网 时间:2024/06/13 22:19
前面讲了三大动画的视图动画,现在就来简单介绍一下帧动画。
现在先来看一下效果:
一.使用xml布局的形式
1.在drawable目录下新建一个xml
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/icon1" android:duration="300"></item> <item android:drawable="@drawable/icon2" android:duration="300"></item> <item android:drawable="@drawable/icon3" android:duration="300"></item> <item android:drawable="@drawable/icon4" android:duration="300"></item> <item android:drawable="@drawable/icon5" android:duration="300"></item> <item android:drawable="@drawable/icon6" android:duration="300"></item></animation-list>2.布局xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/main3_image" android:src="@drawable/icon1" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" /></LinearLayout>3.Java代码
public class Main3Activity extends AppCompatActivity{ private ImageView image; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main3); initView(); } private void initView() { image= (ImageView) findViewById(R.id.main3_image); image.setImageResource(R.drawable.my_frame_animation); AnimationDrawable animationDrawable= (AnimationDrawable) image.getDrawable(); animationDrawable.start(); }}二.使用代码的形式
public class Main3Activity extends AppCompatActivity{ private ImageView image; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main3); initView(); } private void initView() { AnimationDrawable animationDrawable=new AnimationDrawable(); Drawable drawable=getResources().getDrawable(R.drawable.icon1); Drawable drawable2=getResources().getDrawable(R.drawable.icon2); Drawable drawable3=getResources().getDrawable(R.drawable.icon3); Drawable drawable4=getResources().getDrawable(R.drawable.icon4); Drawable drawable5=getResources().getDrawable(R.drawable.icon5); Drawable drawable6=getResources().getDrawable(R.drawable.icon6); //添加图片 animationDrawable.addFrame(drawable,300); animationDrawable.addFrame(drawable2,300); animationDrawable.addFrame(drawable3,300); animationDrawable.addFrame(drawable4,300); animationDrawable.addFrame(drawable5,300); animationDrawable.addFrame(drawable6,300); animationDrawable.setOneShot(false); image.setImageDrawable(animationDrawable); animationDrawable.start(); }}
0 0
- 动画__帧动画
- 转场动画 帧动画
- 动画 AnimationDrawable 帧动画
- 动画----帧动画
- 安卓补间动画、帧动画
- Android动画-帧动画
- Android动画--帧动画
- egret_gif动画(帧动画)
- android动画 -- 帧动画 补间动画
- 属性动画,补间动画,帧动画
- View动画、帧动画、属性动画
- Android动画-帧动画&补间动画
- Android加载动画 旋转动画 、帧动画
- 帧动画、补间动画、属性动画
- 动画(过渡动画、关键帧动画)
- Android动画-帧动画-属性动画
- 帧动画&补间动画&属性动画
- 安卓 动画帧动画基础动画
- 《渗透测试实践指南》 入门笔记 第2章
- Dollar Dayz POJ
- Java 将小写金额转换成大写金额
- Swift 自定义打印信息
- CVPR2016
- 帧动画
- Linux命令行与shell脚本(8)--结构化命令
- The dependency `ReactiveCocoa` is not used in any concrete target.(Cocoapods报错)
- CF 797F Mice and Holes(单调队列优化dp)
- php读取txt文件并将数据插入到数据库
- 如何防止由于卡顿用户多次点击UINavigation push操作。
- 命令行BASH的基本操作
- Ajax的工作原理
- java集合排序