public class LottieDrawable
extends android.graphics.drawable.Drawable
implements android.graphics.drawable.Drawable.Callback
recycleBitmaps() when you are done
or else you will leak bitmaps.
It is preferable to use LottieAnimationView when possible because it
handles bitmap recycling and asynchronous loading
of compositions.
| Constructor and Description |
|---|
LottieDrawable() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAnimatorListener(android.animation.Animator.AnimatorListener listener) |
void |
addAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener) |
void |
addColorFilter(android.graphics.ColorFilter colorFilter)
Add a color filter to all layers
|
void |
addColorFilterToContent(java.lang.String layerName,
java.lang.String contentName,
android.graphics.ColorFilter colorFilter)
Add a color filter to specific content on a specific layer.
|
void |
addColorFilterToLayer(java.lang.String layerName,
android.graphics.ColorFilter colorFilter)
Add a color filter to a whole layer
|
void |
cancelAnimation() |
void |
clearColorFilters()
Clear all color filters on all layers and all content in the layers
|
void |
clearComposition() |
void |
draw(android.graphics.Canvas canvas) |
boolean |
enableMergePathsForKitKatAndAbove() |
void |
enableMergePathsForKitKatAndAbove(boolean enable)
Enable this to get merge path support for devices running KitKat (19) and above.
|
int |
getAlpha() |
LottieComposition |
getComposition() |
int |
getFrame()
Get the currently rendered frame.
|
android.graphics.Bitmap |
getImageAsset(java.lang.String id) |
java.lang.String |
getImageAssetsFolder() |
int |
getIntrinsicHeight() |
int |
getIntrinsicWidth() |
int |
getOpacity() |
PerformanceTracker |
getPerformanceTracker() |
float |
getProgress() |
float |
getScale() |
float |
getSpeed()
Returns the current playback speed.
|
TextDelegate |
getTextDelegate() |
android.graphics.Typeface |
getTypeface(java.lang.String fontFamily,
java.lang.String style) |
boolean |
hasMasks()
Returns whether or not any layers in this composition has masks.
|
boolean |
hasMatte()
Returns whether or not any layers in this composition has a matte layer.
|
void |
invalidateDrawable(android.graphics.drawable.Drawable who)
These Drawable.Callback methods proxy the calls so that this is the drawable that is
actually invalidated, not a child one which will not pass the view's validateDrawable check.
|
void |
invalidateSelf() |
boolean |
isAnimating() |
boolean |
isLooping() |
void |
loop(boolean loop) |
void |
pauseAnimation() |
void |
playAnimation()
Plays the animation from the beginning.
|
void |
recycleBitmaps()
If you have image assets and use
LottieDrawable directly, you must call this yourself. |
void |
removeAnimatorListener(android.animation.Animator.AnimatorListener listener) |
void |
removeAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener) |
void |
resumeAnimation()
Continues playing the animation from its current position.
|
void |
reverseAnimationSpeed()
Reverses the current animation speed.
|
void |
scheduleDrawable(android.graphics.drawable.Drawable who,
java.lang.Runnable what,
long when) |
void |
setAlpha(int alpha) |
void |
setColorFilter(android.graphics.ColorFilter colorFilter) |
boolean |
setComposition(LottieComposition composition) |
void |
setFontAssetDelegate(FontAssetDelegate assetDelegate)
Use this to manually set fonts.
|
void |
setFrame(int frame)
Sets the progress to the specified frame.
|
void |
setImageAssetDelegate(ImageAssetDelegate assetDelegate)
Use this if you can't bundle images with your app.
|
void |
setImagesAssetsFolder(java.lang.String imageAssetsFolder)
If you use image assets, you must explicitly specify the folder in assets/ in which they are
located because bodymovin uses the name filenames across all compositions (img_#).
|
void |
setMaxFrame(int maxFrame)
Sets the maximum frame that the animation will end at when playing or looping.
|
void |
setMaxProgress(float maxProgress)
Sets the maximum progress that the animation will end at when playing or looping.
|
void |
setMinAndMaxFrame(int minFrame,
int maxFrame) |
void |
setMinAndMaxProgress(float minProgress,
float maxProgress) |
void |
setMinFrame(int minFrame)
Sets the minimum frame that the animation will start from when playing or looping.
|
void |
setMinProgress(float minProgress)
Sets the minimum progress that the animation will start from when playing or looping.
|
void |
setPerformanceTrackingEnabled(boolean enabled) |
void |
setProgress(float progress) |
void |
setScale(float scale)
Set the scale on the current composition.
|
void |
setSpeed(float speed)
Sets the playback speed.
|
void |
setTextDelegate(TextDelegate textDelegate) |
void |
unscheduleDrawable(android.graphics.drawable.Drawable who,
java.lang.Runnable what) |
android.graphics.Bitmap |
updateBitmap(java.lang.String id,
android.graphics.Bitmap bitmap)
Allows you to modify or clear a bitmap that was loaded for an image either automatically
through
setImagesAssetsFolder(String) or with an ImageAssetDelegate. |
boolean |
useTextGlyphs() |
applyTheme, canApplyTheme, clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, isAutoMirrored, isFilterBitmap, isStateful, isVisible, jumpToCurrentState, mutate, onBoundsChange, onLayoutDirectionChanged, onLevelChange, onStateChange, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setVisible, unscheduleSelfpublic boolean hasMasks()
public boolean hasMatte()
public boolean enableMergePathsForKitKatAndAbove()
public void enableMergePathsForKitKatAndAbove(boolean enable)
public void setImagesAssetsFolder(java.lang.String imageAssetsFolder)
recycleBitmaps() when you
are done. Calling recycleBitmaps() doesn't have to be final and LottieDrawable
will recreate the bitmaps if needed but they will leak if you don't recycle them.public java.lang.String getImageAssetsFolder()
public void recycleBitmaps()
LottieDrawable directly, you must call this yourself.
Calling recycleBitmaps() doesn't have to be final and LottieDrawable
will recreate the bitmaps if needed but they will leak if you don't recycle them.public boolean setComposition(LottieComposition composition)
public void setPerformanceTrackingEnabled(boolean enabled)
public PerformanceTracker getPerformanceTracker()
public void clearComposition()
public void invalidateSelf()
invalidateSelf in class android.graphics.drawable.Drawablepublic void setAlpha(int alpha)
setAlpha in class android.graphics.drawable.Drawablepublic int getAlpha()
getAlpha in class android.graphics.drawable.Drawablepublic void setColorFilter(android.graphics.ColorFilter colorFilter)
setColorFilter in class android.graphics.drawable.Drawablepublic void addColorFilterToContent(java.lang.String layerName,
java.lang.String contentName,
android.graphics.ColorFilter colorFilter)
layerName - name of the layer where the supplied content name livescontentName - name of the specific content that the color filter is to be appliedcolorFilter - the color filter, null to clear the color filterpublic void addColorFilterToLayer(java.lang.String layerName,
android.graphics.ColorFilter colorFilter)
layerName - name of the layer that the color filter is to be appliedcolorFilter - the color filter, null to clear the color filterpublic void addColorFilter(android.graphics.ColorFilter colorFilter)
colorFilter - the color filter, null to clear all color filterspublic void clearColorFilters()
public int getOpacity()
getOpacity in class android.graphics.drawable.Drawablepublic void draw(android.graphics.Canvas canvas)
draw in class android.graphics.drawable.Drawablepublic void playAnimation()
public void resumeAnimation()
public void setMinFrame(int minFrame)
public void setMinProgress(float minProgress)
public void setMaxFrame(int maxFrame)
public void setMaxProgress(float maxProgress)
public void setMinAndMaxFrame(int minFrame,
int maxFrame)
setMinFrame(int),
setMaxFrame(int)public void setMinAndMaxProgress(float minProgress,
float maxProgress)
setMinProgress(float),
setMaxProgress(float)public void reverseAnimationSpeed()
setSpeed(float),
playAnimation(),
resumeAnimation()public void setSpeed(float speed)
public float getSpeed()
public void addAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener)
public void removeAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener)
public void addAnimatorListener(android.animation.Animator.AnimatorListener listener)
public void removeAnimatorListener(android.animation.Animator.AnimatorListener listener)
public void setFrame(int frame)
public int getFrame()
public void setProgress(float progress)
public void loop(boolean loop)
public boolean isLooping()
public boolean isAnimating()
public void setScale(float scale)
public void setImageAssetDelegate(ImageAssetDelegate assetDelegate)
public void setFontAssetDelegate(FontAssetDelegate assetDelegate)
public void setTextDelegate(TextDelegate textDelegate)
public TextDelegate getTextDelegate()
public boolean useTextGlyphs()
public float getScale()
public LottieComposition getComposition()
public void cancelAnimation()
public void pauseAnimation()
public float getProgress()
public int getIntrinsicWidth()
getIntrinsicWidth in class android.graphics.drawable.Drawablepublic int getIntrinsicHeight()
getIntrinsicHeight in class android.graphics.drawable.Drawablepublic android.graphics.Bitmap updateBitmap(java.lang.String id,
android.graphics.Bitmap bitmap)
setImagesAssetsFolder(String) or with an ImageAssetDelegate.public android.graphics.Bitmap getImageAsset(java.lang.String id)
public android.graphics.Typeface getTypeface(java.lang.String fontFamily,
java.lang.String style)
public void invalidateDrawable(android.graphics.drawable.Drawable who)
invalidateDrawable in interface android.graphics.drawable.Drawable.Callbackpublic void scheduleDrawable(android.graphics.drawable.Drawable who,
java.lang.Runnable what,
long when)
scheduleDrawable in interface android.graphics.drawable.Drawable.Callbackpublic void unscheduleDrawable(android.graphics.drawable.Drawable who,
java.lang.Runnable what)
unscheduleDrawable in interface android.graphics.drawable.Drawable.Callback