============================首先看看官網上關于Frame animation的介紹================================
An animation defined in XML that shows a sequence of images in order (like a film).
<dl></dl>
<dt>FILE LOCATION:</dt>
<dd></dd>
<code>res/drawable/filename.xml</code>
The filename will be used as the resource ID.
<dt>COMPILED RESOURCE DATATYPE:</dt>
<dt>RESOURCE REFERENCE:</dt>
In XML: <code>@[package:]drawable.filename</code>
<dt>SYNTAX:</dt>
ELEMENTS:
<dt><code><animation-list></code></dt>
Required. This must be the root element. Contains one or more <code><item></code> elements.
attributes:
<dt><code>android:oneshot</code></dt>
Boolean. "true" if you want to perform the animation once; "false" to loop the animation.
<dt><code><item></code></dt>
<dd>A single frame of animation. Must be a child of a <code><animation-list></code> element.</dd>
<dt><code>android:drawable</code></dt>
Drawable resource. The drawable to use for this frame.
<dt><code>android:duration</code></dt>
Integer. The duration to show this frame, in milliseconds.
============================下面通過一個小案例來學習Frame animation================================
step1:建立一個Android項目FrameAnimationDemo
step2:準備好該應用使用的圖檔,用來做Frame Animation的,并将動畫放入drawable目錄下
step3:建立一個用來描述Frame動畫的xml檔案,res/anim/frame.xml
step4:該應用的布局檔案 res/layout/main.xml
step5:該應用的主檔案,FrameActivity.java
效果如下:
==================================下面看一個gif動畫===========================================
=================================================================================================
作者:歐陽鵬 歡迎轉載,與人分享是進步的源泉!
==================================================================================================