- 浏览: 124706 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
spysoos:
谢谢分享了
学习笔记:自定义样式(style)与主题(theme) -
jinnianshilongnian:
早起~~ 写blog -
zangwenyang:
常见的序列模式挖掘算法1GSP算法2prefixspan3di ...
序列模式挖掘 -
zcllgj:
请问一下,如何像天翼空间一样调用系统apn?
Android APN设置及获得手机号(转载) -
zangwenyang:
isRunning()
Indicates whether ...
Animation2
AnimationDrawable
包android.graphics.drawable.AnimationDrawable
Class OverviewAn object used to create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background.
通过一系列可以绘制的对象,可以创建一帧一帧的动画的类,而且可以用作view的background
The simplest way to create a frame-by-frame animation is to define the animation in an XML file, placed in the res/drawable/ folder, and set it as the background to a View object. Then, call run() to start the animation.
创建frame动画的最最简单的方法是通过动画的xml文件(放在res/drawble下面),把它设置为一个view的背景,然后start该动画
An AnimationDrawable defined in XML consists of a single <animation-list> element, and a series of nested <item> tags. Each item defines a frame of the animation. See the example below.
AnimationDrawble可以定义xml根元素是<animation-list>子元素是一系列的<item>,每一个item都是每一个动画的一帧,看下面的例子
:
spin_animation.xml file in res/drawable/ folder
<!-- Animation frames are wheel0.png -- wheel5.png files inside the
res/drawable/ folder -->
<animation-list android:id="selected" android:oneshot="false">
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />
<item android:drawable="@drawable/wheel2" android:duration="50" />
<item android:drawable="@drawable/wheel3" android:duration="50" />
<item android:drawable="@drawable/wheel4" android:duration="50" />
<item android:drawable="@drawable/wheel5" android:duration="50" />
</animation-list>Here is the code to load and play this animation.
下面的是对动画的调用
// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start()
Summary
XML Attributes |
|||||||||||
Attribute Name |
Related Method |
Description |
|
|
|
|
|
|
|
|
|
|
Reference to a drawable resource to use for the frame. Item的元素,指定当前帧的动画资源 |
|
|
|
|
|
|
|
|
|
|
|
Amount of time (in milliseconds) to display this frame. 一帧持续的时间 |
|
|
|
|
|
|
|
|
|
|
|
If true, the animation will only run a single time and then stop. 是否只播放一次,默认是true |
|
|
|
|
|
|
|
|
|
|
|
If true, allows the drawable's padding to change based on the current state that is selected. 可以更改动画资源的padding |
|
|
|
|
|
|
|
|
|
|
|
Provides initial visibility state of the drawable; the default value is false.
|
|
|
|
|
|
|
|
|
|
Public Constructors |
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
Public Methods |
|||||||||||
void |
addFrame(Drawable frame, int duration) Add a frame to the animation 增加一帧 |
|
|
|
|
|
|
|
|
|
|
int |
getDuration(int i) 获得持续时间 |
|
|
|
|
|
|
|
|
|
|
getFrame(int index) 获得第几个frame |
|
|
|
|
|
|
|
|
|
|
|
int |
获得几个frame |
|
|
|
|
|
|
|
|
|
|
void |
inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
|
|
|
|
|
|
|
|
|
|
|
boolean |
是否循环播放 |
|
|
|
|
|
|
|
|
|
|
|
|
评论
Indicates whether the animation is currently running or not.
动画是否在播放
mutate()
Make this drawable mutable.
run()
This method exists for implementation purpose only and should not be called directly.
这个方法是留给重载时候实现,不能够从代码中直接调用的。调用start方法时候会默认调用run方法
setOneShot(boolean oneShot)
Sets whether the animation should play once or repeat.
设置播放一次
setVisible(boolean visible, boolean restart)
Set whether this Drawable is visible.
设置动画是否可见,如果restart是true,重新播放动画(即使动画已经显示了)
start()
Starts the animation, looping if necessary.
播放动画
stop()
Stops the animation.
停止播放动画
unscheduleSelf(Runnable what)
Use the current Drawable.Callback implementation to have this Drawable unscheduled.
发表评论
-
卸载 android 系统app
2013-12-29 09:17 766☆1.下载一键安全root软 ... -
最新手机语音助手的调研
2013-01-27 07:23 772几个助手的分析 虫洞语音助手 智能360 ... -
ListAdapter 没有数据时候会如何处理
2011-09-10 09:20 726The View with the empty id is u ... -
怎样更改虚拟机vmware的硬盘大小
2010-08-02 12:17 4308由于第一次使用虚拟机,第一次操作,结果给操作系统分硬盘的时 ... -
how to develop android under Ubuntu
2010-07-31 15:04 01 install java ubuntu 10.04已经去 ... -
android内存优化
2010-05-02 19:57 1198创建或其他方式获得的对象如不再使用,则主动将其置为nu ... -
android注意事项。随时补充
2010-03-27 11:53 789这里维护一些小的知识点,给自己提醒 1 所有的andr ... -
Gallary控件
2010-03-23 23:00 908gallery翻译了sdk zwyproject 演示了关键 ... -
ContentProvider 翻译
2010-03-23 20:05 1275简单的翻译了一下sdk 在应用中声明 <pr ... -
Android APN设置及获得手机号(转载)
2010-03-23 19:04 4128转载请注明出处:http://blog.csdn.net/ ... -
content provider(转载)
2010-03-23 10:50 1018Study on Android【二】--ContentPro ... -
location包
2010-03-18 18:04 1196Interfaces GpsStatus.Li ... -
获取当前locale
2010-03-17 16:14 1561Resources res = ... -
在 Android 上使用 XML(转)
2010-01-28 21:09 851本来研究一下android上面的xml解析器。发现了网上有一篇 ... -
android u8220刷机
2010-01-17 12:17 3314先下载个T Mobile12月官方ROM,改进了系统的信号等问 ... -
android 模拟器使用
2010-01-08 15:37 1570一。模拟器安装和启动 ... -
animation1
2009-12-31 16:26 1964参考了网上一个被转载很多次的帖子,加入 ... -
ProgressBar基本知识
2009-11-27 15:20 4522ProgressBar位于android.view包下面。 在 ... -
给android应用程序签名
2009-11-09 16:20 2346Android程序的签名和Symbia ... -
spinner使用
2009-10-29 07:41 1930spinner是一个经常用的控件,简单总结一下他的使用 1 ...
相关推荐
ulead gif animation教程
插件用于制作2d动画,zaiunity里使用十分方便,分享给大家
This comprehensive work provides the fundamentals of computer facial animation and brings into sharper focus techniques that are becoming mainstream in the industry. Over the past decade, since the ...
Animation 动画详解 Animation 动画详解 Animation 动画详解Animation 动画详解Animation 动画详解Animation 动画详解
• 2、《Animation动画详解(二)——Interpolator插值器》 • 3、《Animation动画详解(三)—— 代码生成alpha、scale、translate、rotate、set及插值器动画》 • 4、《Animation动画详解(四)——ValueAnimator...
微信小程序实现animation动画,具体内容如下 1. 创建动画实例 wx.createAnimation(OBJECT) 创建一个动画实例animation。调用实例的方法来描述动画。最后通过动画实例的export方法导出动画数据传递给组件的...
Animation_2(ListView动画)
Expand your imagination by letting go of the limitations of traditional animation mediums, software packages, or workflows and integrating 2D and 3D assets. With the updated and expanded second ...
core animation cook bookcore animation cook bookcore animation cook bookcore animation cook bookcore animation cook book
AE2Unity After Effect To Unity Animation AE动画导入到Unity
FoundationAS3Animation.pdfFoundationAS3Animation.pdfFoundationAS3Animation.pdf
Animation GIF ActiveX is a 32bit OLE Control Module to display GIF file(still and animation, GIF87a and GIF89a) in OLE Container. It supports all GIF89a standard, including transparent, animation, ...
MeshAnimation.unitypackage
About This Book Create and export models and animation sequences to Unity from 3ds max and Maya Prepare character models and animation for games using Mecanim’s rigging tools Retarget, adjust, and ...
再drawable目录下新建animation1文件和animation2文件 一个是按顺序显示动画,一个是倒序显示动画, 顺序显示动画文件:animation1.xml <?xml version=1.0 encoding=utf-8?> <!-- 根标签为animation-...
Animation in a window
VB Animation动画示例 VB Animation动画示例
Android ViewFlipper Animation 使用
RPG Character Mecanim Animation Pack 最新版本收錄超過 1000 個專業動作,版本更新速度快,持續加入新的動作,提供物理基礎的控制腳本,並且支援 XBox360 控制器,您可以直接拖曳到遊戲專案使用。 RPG Character ...