ImageAnimationElementpublic class FrameAnimationElement extends ElementContainer
Animations defined by the element objects are mainly used as the background of component objects.
Element.ConstantState, Element.OnBoundsChangeListener, Element.OnChangeListener, Element.OnLayoutDirectionChangeListener, Element.OnRankChangeListenerElementContainer.ElementStateALPHA_DEFAULT, ALPHA_MAX, ALPHA_MIN, DEFAULT_BOUNDS_RECT, MAX_RANK, MIN_RANK| 构造器 | 说明 |
|---|---|
FrameAnimationElement() |
Default constructor used to create a
FrameAnimationElement object. |
FrameAnimationElement(Context context,
int xmlId) |
Creates a
FrameAnimationElement object based on the specified XML resource. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addFrame(Element frame,
int duration) |
Adds an element frame to an animation.
|
boolean |
getDisposeMode() |
Checks whether dynamic decoding is enabled for this frame animation.
|
int |
getDuration(int index) |
Obtains the duration of a specified frame in an animation.
|
Element |
getFrame(int index) |
Obtains the frame of a specified index.
|
int |
getNumberOfFrames() |
Obtains the number of frames in an animation.
|
int |
getPreDecodeFrames() |
Obtains the number of frames to be decoded before this animation is displayed.
|
boolean |
isOneShot() |
Checks whether an animation is played only once.
|
void |
setDisposeMode(boolean isDisposeMode) |
Sets dynamic decoding for this frame animation.
|
void |
setOneShot(boolean oneShot) |
Sets whether to play an animation only once.
|
boolean |
setPreDecodeFrames(int preDecodeFrames) |
Sets the number of frames to be decoded before this animation is displayed.
|
void |
start() |
Starts an animation.
|
void |
stop() |
Stops an animation.
|
clearColorMatrix, drawToCanvas, getAlpha, getBounds, getCallback, getColorMatrix, getHeight, getLayoutDirection, getMinHeight, getMinWidth, getPadding, getRank, getStateColorMode, getVisible, getWidth, isInheritDirection, isVisible, release, setAlpha, setBounds, setBounds, setCallback, setColorMatrix, setInheritDirection, setLayoutDirection, setOnBoundsChangeListener, setOnLayoutDirectionChangeListener, setOnRankChangeListener, setRank, setStateColor, setStateColorList, setStateColorMode, setVisibleaddChildElement, getChildElement, getChildElementCount, getCurrentElement, getElementState, getEnterFadeDuration, getExitFadeDuration, getFadeInEffectPeriod, getFadeOutEffectPeriod, isStateful, selectElement, setElementState, setEnterFadeDuration, setExitFadeDuration, skipAnimationpublic FrameAnimationElement()
FrameAnimationElement object.public FrameAnimationElement(Context context, int xmlId)
FrameAnimationElement object based on the specified XML resource.context - Indicates the application context.xmlId - Indicates the ID of the XML resource.public void start()
public void stop()
public int getNumberOfFrames()
public Element getFrame(int index)
index - Indicates the specified index used to obtain the frame.public int getDuration(int index)
index - Indicates the index of the specified frame.public boolean isOneShot()
True if the animation is played only once; returns False otherwise.public void setOneShot(boolean oneShot)
oneShot - Indicates whether the animation is played only once. Value true means that the animation
is played only once, and false means the opposite.public void addFrame(Element frame, int duration)
frame - Indicates the element frame to add.duration - Indicates the duration of the element frame, in milliseconds.public void setDisposeMode(boolean isDisposeMode)
isDisposeMode - Specifies whether to enable dynamic decoding for this frame animation.
The value true means to enable dynamic decoding, and
false means the opposite. If you enable dynamic decoding,
you must also call setPreDecodeFrames(int) to set the number of frames to be decoded.
Enabling dynamic decoding saves random-access memory (RAM) but may consumes more power.public boolean getDisposeMode()
true if dynamic decoding is enabled; returns false otherwise.public boolean setPreDecodeFrames(int preDecodeFrames)
preDecodeFrames - Indicates the number of frames to set. The value ranges from 1 to 30.True if the preDecodeFrames is set properly; returns False otherwise.public int getPreDecodeFrames()
-1 if dynamic decoding is disabled.