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 |
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() |
android.graphics.Bitmap |
getImageAsset(java.lang.String id) |
java.lang.String |
getImageAssetsFolder() |
int |
getIntrinsicHeight() |
int |
getIntrinsicWidth() |
int |
getOpacity() |
PerformanceTracker |
getPerformanceTracker() |
float |
getProgress() |
float |
getScale() |
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 |
playAnimation() |
void |
playAnimation(float startProgress,
float endProgress) |
void |
playAnimation(int startFrame,
int endFrame) |
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() |
void |
resumeReverseAnimation() |
void |
reverseAnimation() |
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 |
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) |
void |
setMaxProgress(float maxProgress) |
void |
setMinAndMaxFrame(int minFrame,
int maxFrame) |
void |
setMinAndMaxProgress(float minProgress,
float maxProgress) |
void |
setMinFrame(int minFrame) |
void |
setMinProgress(float minProgress) |
void |
setPerformanceTrackingEnabled(boolean enabled) |
void |
setProgress(float progress) |
void |
setScale(float scale)
Set the scale on the current composition.
|
void |
setSpeed(float 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 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 loop(boolean loop)
public boolean isLooping()
public boolean isAnimating()
public void playAnimation()
public void resumeAnimation()
public void playAnimation(int startFrame,
int endFrame)
public void playAnimation(float startProgress,
float endProgress)
public void resumeReverseAnimation()
public void reverseAnimation()
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)
public void setMinAndMaxProgress(float minProgress,
float maxProgress)
public void setSpeed(float speed)
public void setProgress(float progress)
public float getProgress()
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 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 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