Android 动画学习记录(二)---frame动画

Frame动画

文件目录:res/drawable/filename.xml
编译资源数据类型 AnimationDrawable
资源引用:
Java: R.drawable.filename
XML: @[package:]drawable.filename

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
   android:oneshot=["true" | "false"] >
	<item
		android:drawable="@[package:]drawable/drawable_resource_name"
		android:duration="integer" />
</animation-list>

必须作为根元素,包含一个或者多个根元素
属性:android:oneshot :true:只执行一次动画,false:循环执行


A single frame of animation. Must be a child of a element.
一帧独立动画,必须是的子元素。
属性
android:drawable
Drawable资源,用于这一帧的图片。
android:duration
Integer类型.该帧的时长,单位为毫秒milliseconds.
res/drawable/voice.xml: 这个动画就是每200毫秒循环显示图片,fasong1,fasong2,fasong3 如果oneshot 为true 则只执行一次

1
2
3
4
5
6
7
<?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/fasong1" android:duration="200" />
    <item android:drawable="@drawable/fasong2" android:duration="200" />
    <item android:drawable="@drawable/fasong3" android:duration="200" />
</animation-list>

调用代码:

// 帧动画启动
animationDrawable = (AnimationDrawable) imageView.getBackground();
animationDrawable.start();
// 帧动画停止
animationDrawable.stop();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值