-
- All Implemented Interfaces:
-
android.graphics.drawable.Animatable,android.graphics.drawable.Drawable.Callback
public class LottieDrawable extends Drawable implements Drawable.Callback, Animatable
This can be used to show an lottie animation in any place that would normally take a drawable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceLottieDrawable.RepeatMode
-
Field Summary
Fields Modifier and Type Field Description private LottieCompositioncompositionprivate booleansafeModeprivate StringimageAssetsFolderprivate ImageAssetDelegateimageAssetDelegateprivate Map<String, Typeface>fontMapStringdefaultFontFileExtensionFontAssetDelegatefontAssetDelegateTextDelegatetextDelegateprivate booleanmaintainOriginalImageBoundsprivate booleanclipToCompositionBoundsprivate intalphaprivate booleanperformanceTrackingEnabledprivate booleanoutlineMasksAndMattesprivate booleanisApplyingOpacityToLayersEnabledprivate booleanclipTextToBoundingBoxprivate RenderModerenderModeprivate AsyncUpdatesasyncUpdatespublic final static intRESTARTpublic final static intREVERSEpublic final static intINFINITE
-
Constructor Summary
Constructors Constructor Description LottieDrawable()
-
Method Summary
Modifier and Type Method Description LottieCompositiongetComposition()booleansetComposition(LottieComposition composition)Create a composition with LottieCompositionFactory voidsetSafeMode(boolean safeMode)If you are experiencing a device specific crash that happens during drawing, you can set this to truefor those devices. StringgetImageAssetsFolder()voidsetImageAssetDelegate(ImageAssetDelegate assetDelegate)Use this if you can't bundle images with your app. voidsetFontMap(@Nullable() Map<String, Typeface> fontMap)Set a map from font name keys to Typefaces.The keys can be in the form:* fontFamily* fontFamily-fontStyle* fontNameAll 3 are defined as fName, fFamily, and fStyle in the Lottie file. voidsetDefaultFontFileExtension(String extension)By default, Lottie will look in src/assets/fonts/FONT_NAME.ttfwhere FONT_NAME is the fFamily specified in your Lottie file.If your fonts have a different extension, you can override thedefault here. voidsetFontAssetDelegate(FontAssetDelegate assetDelegate)Use this to manually set fonts. TextDelegategetTextDelegate()voidsetTextDelegate(TextDelegate textDelegate)booleangetMaintainOriginalImageBounds()When true, dynamically set bitmaps will be drawn with the exact bounds of the original animation, regardless of the bitmap size.When false, dynamically set bitmaps will be drawn at the top left of the original image but with its own bounds. voidsetMaintainOriginalImageBounds(boolean maintainOriginalImageBounds)When true, dynamically set bitmaps will be drawn with the exact bounds of the original animation, regardless of the bitmap size.When false, dynamically set bitmaps will be drawn at the top left of the original image but with its own bounds. booleangetClipToCompositionBounds()Gets whether or not Lottie should clip to the original animation composition bounds. voidsetClipToCompositionBounds(boolean clipToCompositionBounds)Sets whether or not Lottie should clip to the original animation composition bounds. intgetAlpha()voidsetAlpha(@IntRange(from = 0, to = 255) int alpha)voidsetPerformanceTrackingEnabled(boolean enabled)voidsetOutlineMasksAndMattes(boolean outline)Enable this to debug slow animations by outlining masks and mattes. booleanisApplyingOpacityToLayersEnabled()booleangetClipTextToBoundingBox()voidsetClipTextToBoundingBox(boolean clipTextToBoundingBox)When true, if there is a bounding box set on a text layer (paragraph text), any textthat overflows past its height will not be drawn. RenderModegetRenderMode()Returns the actual render mode being used. voidsetRenderMode(RenderMode renderMode)Call this to set whether or not to render with hardware or software acceleration.Lottie defaults to Automatic which will use hardware acceleration unless:1) There are dash paths and the device is pre-Pie.2) There are more than 4 masks and mattes and the device is pre-Pie.Hardware acceleration is generally faster for those devices unlessthere are many large mattes and masks in which case there is a lotof GPU uploadTexture thrashing which makes it much slower. AsyncUpdatesgetAsyncUpdates()Returns the current value of AsyncUpdates. voidsetAsyncUpdates(@Nullable() AsyncUpdates asyncUpdates)**Note: this API is experimental and may changed. booleanhasMasks()Returns whether or not any layers in this composition has masks. booleanhasMatte()Returns whether or not any layers in this composition has a matte layer. booleanenableMergePathsForKitKatAndAbove()voidenableMergePathsForKitKatAndAbove(boolean enable)Enable this to get merge path support for devices running KitKat (19) and above.Deprecated: Use enableFeatureFlag(LottieFeatureFlags.FeatureFlag. booleanisMergePathsEnabledForKitKatAndAbove()voidenableFeatureFlag(LottieFeatureFlag flag, boolean enable)Enable the specified feature for this drawable. booleanisFeatureFlagEnabled(LottieFeatureFlag flag)voidsetImagesAssetsFolder(@Nullable() String imageAssetsFolder)If you use image assets, you must explicitly specify the folder in assets/ in which they arelocated because bodymovin uses the name filenames across all compositions (img_#).Do NOT rename the images themselves. booleangetAsyncUpdatesEnabled()Similar to getAsyncUpdates except it returns the actualboolean value for whether async updates are enabled or not.This is useful when the mode is automatic and you want to knowwhether automatic is defaulting to enabled or not. PerformanceTrackergetPerformanceTracker()voidsetApplyingOpacityToLayersEnabled(boolean isApplyingOpacityToLayersEnabled)Sets whether to apply opacity to the each layer instead of shape. voiddisableExtraScaleModeInFitXY()This API no longer has any effect. voidclearComposition()voidinvalidateSelf()voidsetColorFilter(@Nullable() ColorFilter colorFilter)intgetOpacity()voiddraw(@NonNull() Canvas canvas)voiddraw(Canvas canvas, Matrix matrix)To be used by lottie-compose only. voidstart()voidstop()booleanisRunning()voidplayAnimation()Plays the animation from the beginning. MarkergetMarkerForAnimationsDisabled()This method is used to get the marker for animations when system animations are disabled.It iterates over the list of allowed reduced motion markers and returns the first non-null marker it finds.If no non-null marker is found, it returns null. voidendAnimation()voidresumeAnimation()Continues playing the animation from its current position. voidsetMinFrame(int minFrame)Sets the minimum frame that the animation will start from when playing or looping. floatgetMinFrame()Returns the minimum frame set by setMinFrame or setMinProgress voidsetMinProgress(float minProgress)Sets the minimum progress that the animation will start from when playing or looping. voidsetMaxFrame(int maxFrame)Sets the maximum frame that the animation will end at when playing or looping. floatgetMaxFrame()Returns the maximum frame set by setMaxFrame or setMaxProgress voidsetMaxProgress(@FloatRange(from = 0f, to = 1f) float maxProgress)Sets the maximum progress that the animation will end at when playing or looping. voidsetMinFrame(String markerName)Sets the minimum frame to the start time of the specified marker. voidsetMaxFrame(String markerName)Sets the maximum frame to the start time + duration of the specified marker. voidsetMinAndMaxFrame(String markerName)Sets the minimum and maximum frame to the start time and start time + durationof the specified marker. voidsetMinAndMaxFrame(String startMarkerName, String endMarkerName, boolean playEndMarkerStartFrame)Sets the minimum and maximum frame to the start marker start and the maximum frame to the end marker start.playEndMarkerStartFrame determines whether or not to play the frame that the end marker is on. voidsetMinAndMaxFrame(int minFrame, int maxFrame)voidsetMinAndMaxProgress(@FloatRange(from = 0f, to = 1f) float minProgress, @FloatRange(from = 0f, to = 1f) float maxProgress)voidreverseAnimationSpeed()Reverses the current animation speed. voidsetSpeed(float speed)Sets the playback speed. floatgetSpeed()Returns the current playback speed. voidaddAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)voidremoveAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)voidremoveAllUpdateListeners()voidaddAnimatorListener(Animator.AnimatorListener listener)voidremoveAnimatorListener(Animator.AnimatorListener listener)voidremoveAllAnimatorListeners()voidaddAnimatorPauseListener(Animator.AnimatorPauseListener listener)voidremoveAnimatorPauseListener(Animator.AnimatorPauseListener listener)voidsetFrame(int frame)Sets the progress to the specified frame.If the composition isn't set yet, the progress will be set to the frame whenit is. intgetFrame()Get the currently rendered frame. voidsetProgress(@FloatRange(from = 0f, to = 1f) float progress)voidloop(boolean loop)voidsetRepeatMode(int mode)Defines what this animation should do when it reaches the end. intgetRepeatMode()Defines what this animation should do when it reaches the end. voidsetRepeatCount(int count)Sets how many times the animation should be repeated. intgetRepeatCount()Defines how many times the animation should repeat. booleanisLooping()booleanisAnimating()booleananimationsEnabled(@Nullable() Context context)voidsetSystemAnimationsAreEnabled(Boolean areEnabled)Tell Lottie that system animations are disabled. voidsetIgnoreDisabledSystemAnimations(boolean ignore)Allows ignoring system animations settings, therefore allowing animations to run even if they are disabled. voidsetUseCompositionFrameRate(boolean useCompositionFrameRate)Lottie files can specify a target frame rate. booleanuseTextGlyphs()voidcancelAnimation()voidpauseAnimation()floatgetProgress()intgetIntrinsicWidth()intgetIntrinsicHeight()List<KeyPath>resolveKeyPath(KeyPath keyPath)Takes a KeyPath, potentially with wildcards or globstars and resolve it to a list ofzero or more actual Keypaths that exist in the current animation. <T> voidaddValueCallback(KeyPath keyPath, T property, @Nullable() LottieValueCallback<T> callback)Add an property callback for the specified KeyPath. <T> voidaddValueCallback(KeyPath keyPath, T property, SimpleLottieValueCallback<T> callback)Overload of addValueCallback that takes an interface. BitmapupdateBitmap(String id, @Nullable() Bitmap bitmap)Allows you to modify or clear a bitmap that was loaded for an image either automaticallythrough setImagesAssetsFolder or with an ImageAssetDelegate. BitmapgetImageAsset(String id)BitmapgetBitmapForId(String id)Returns the bitmap that will be rendered for the given id in the Lottie animation file.The id is the asset reference id stored in the "id" property of each object in the "assets" array. LottieImageAssetgetLottieImageAssetForId(String id)Returns the LottieImageAsset that will be rendered for the given id in the Lottie animation file.The id is the asset reference id stored in the "id" property of each object in the "assets" array. TypefacegetTypeface(Font font)booleansetVisible(boolean visible, boolean restart)voidinvalidateDrawable(@NonNull() Drawable who)These Drawable.Callback methods proxy the calls so that this is the drawable that isactually invalidated, not a child one which will not pass the view's validateDrawable check. voidscheduleDrawable(@NonNull() Drawable who, @NonNull() Runnable what, long when)voidunscheduleDrawable(@NonNull() Drawable who, @NonNull() Runnable what)-
Methods inherited from class android.graphics.drawable.Drawable
applyTheme, canApplyTheme, clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromStream, createFromXml, createFromXmlInner, draw, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpacity, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, hasFocusStateSpecified, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isStateful, isVisible, jumpToCurrentState, mutate, onLayoutDirectionChanged, resolveOpacity, scheduleSelf, setAlpha, setAutoMirrored, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintBlendMode, setTintList, setTintMode, setVisible, unscheduleSelf -
Methods inherited from class android.graphics.drawable.Drawable.Callback
invalidateDrawable, scheduleDrawable, unscheduleDrawable -
Methods inherited from class android.graphics.drawable.Animatable
isRunning, start, stop -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getComposition
LottieComposition getComposition()
-
setComposition
boolean setComposition(LottieComposition composition)
Create a composition with LottieCompositionFactory
-
setSafeMode
void setSafeMode(boolean safeMode)
If you are experiencing a device specific crash that happens during drawing, you can set this to truefor those devices. If set to true, draw will be wrapped with a try/catch which will cause Lottie torender an empty frame rather than crash your app.
Ideally, you will never need this and the vast majority of apps and animations won't. However, you may usethis for very specific cases if absolutely necessary.
-
getImageAssetsFolder
@Nullable() String getImageAssetsFolder()
-
setImageAssetDelegate
void setImageAssetDelegate(ImageAssetDelegate assetDelegate)
Use this if you can't bundle images with your app. This may be useful if you download theanimations from the network or have the images saved to an SD Card. In that case, Lottiewill defer the loading of the bitmap to this delegate.
Be wary if you are using many images, however. Lottie is designed to work with vector shapesfrom After Effects. If your images look like they could be represented with vector shapes,see if it is possible to convert them to shape layers and re-export your animation. Checkthe documentation at http://airbnb.io/lottie for more information about importing shapes fromSketch or Illustrator to avoid this.
-
setFontMap
void setFontMap(@Nullable() Map<String, Typeface> fontMap)
Set a map from font name keys to Typefaces.The keys can be in the form:* fontFamily* fontFamily-fontStyle* fontNameAll 3 are defined as fName, fFamily, and fStyle in the Lottie file.
If you change a value in fontMap, create a new map or call invalidateSelf. Setting the same map again will noop.
-
setDefaultFontFileExtension
void setDefaultFontFileExtension(String extension)
By default, Lottie will look in src/assets/fonts/FONT_NAME.ttfwhere FONT_NAME is the fFamily specified in your Lottie file.If your fonts have a different extension, you can override thedefault here.
Alternatively, you can use setFontAssetDelegate for more control.
-
setFontAssetDelegate
void setFontAssetDelegate(FontAssetDelegate assetDelegate)
Use this to manually set fonts.
-
getTextDelegate
@Nullable() TextDelegate getTextDelegate()
-
setTextDelegate
void setTextDelegate(TextDelegate textDelegate)
-
getMaintainOriginalImageBounds
boolean getMaintainOriginalImageBounds()
When true, dynamically set bitmaps will be drawn with the exact bounds of the original animation, regardless of the bitmap size.When false, dynamically set bitmaps will be drawn at the top left of the original image but with its own bounds.
Defaults to false.
-
setMaintainOriginalImageBounds
void setMaintainOriginalImageBounds(boolean maintainOriginalImageBounds)
When true, dynamically set bitmaps will be drawn with the exact bounds of the original animation, regardless of the bitmap size.When false, dynamically set bitmaps will be drawn at the top left of the original image but with its own bounds.
Defaults to false.
-
getClipToCompositionBounds
boolean getClipToCompositionBounds()
Gets whether or not Lottie should clip to the original animation composition bounds.
Defaults to true.
-
setClipToCompositionBounds
void setClipToCompositionBounds(boolean clipToCompositionBounds)
Sets whether or not Lottie should clip to the original animation composition bounds.
Defaults to true.
-
getAlpha
int getAlpha()
-
setPerformanceTrackingEnabled
void setPerformanceTrackingEnabled(boolean enabled)
-
setOutlineMasksAndMattes
void setOutlineMasksAndMattes(boolean outline)
Enable this to debug slow animations by outlining masks and mattes. The performance overhead of the masks and mattes willbe proportional to the surface area of all of the masks/mattes combined.
DO NOT leave this enabled in production.
-
isApplyingOpacityToLayersEnabled
boolean isApplyingOpacityToLayersEnabled()
-
getClipTextToBoundingBox
boolean getClipTextToBoundingBox()
-
setClipTextToBoundingBox
void setClipTextToBoundingBox(boolean clipTextToBoundingBox)
When true, if there is a bounding box set on a text layer (paragraph text), any textthat overflows past its height will not be drawn.
-
getRenderMode
RenderMode getRenderMode()
Returns the actual render mode being used. It will always be HARDWARE or SOFTWARE.When the render mode is set to AUTOMATIC, the value will be derived from useSoftwareRendering.
-
setRenderMode
void setRenderMode(RenderMode renderMode)
Call this to set whether or not to render with hardware or software acceleration.Lottie defaults to Automatic which will use hardware acceleration unless:1) There are dash paths and the device is pre-Pie.2) There are more than 4 masks and mattes and the device is pre-Pie.Hardware acceleration is generally faster for those devices unlessthere are many large mattes and masks in which case there is a lotof GPU uploadTexture thrashing which makes it much slower.
In most cases, hardware rendering will be faster, even if you have mattes and masks.However, if you have multiple mattes and masks (especially large ones), youshould test both render modes. You should also test on pre-Pie and Pie+ devicesbecause the underlying rendering engine changed significantly.
-
getAsyncUpdates
AsyncUpdates getAsyncUpdates()
Returns the current value of AsyncUpdates. Refer to the docs for AsyncUpdates for more info.
-
setAsyncUpdates
void setAsyncUpdates(@Nullable() AsyncUpdates asyncUpdates)
**Note: this API is experimental and may changed.**
Sets the current value for AsyncUpdates. Refer to the docs for AsyncUpdates for more info.
-
hasMasks
boolean hasMasks()
Returns whether or not any layers in this composition has masks.
-
hasMatte
boolean hasMatte()
Returns whether or not any layers in this composition has a matte layer.
-
enableMergePathsForKitKatAndAbove
@Deprecated() boolean enableMergePathsForKitKatAndAbove()
-
enableMergePathsForKitKatAndAbove
@Deprecated() void enableMergePathsForKitKatAndAbove(boolean enable)
Enable this to get merge path support for devices running KitKat (19) and above.Deprecated: Use enableFeatureFlag(LottieFeatureFlags.FeatureFlag.MergePathsApi19, enable)
Merge paths currently don't work if the the operand shape is entirely contained within thefirst shape. If you need to cut out one shape from another shape, use an even-odd fill typeinstead of using merge paths.
-
isMergePathsEnabledForKitKatAndAbove
@Deprecated() boolean isMergePathsEnabledForKitKatAndAbove()
-
enableFeatureFlag
void enableFeatureFlag(LottieFeatureFlag flag, boolean enable)
Enable the specified feature for this drawable.
Features guarded by LottieFeatureFlags are experimental or only supported by a subset of API levels.Please ensure that the animation supported by the enabled feature looks acceptable across alltargeted API levels.
-
isFeatureFlagEnabled
boolean isFeatureFlagEnabled(LottieFeatureFlag flag)
-
setImagesAssetsFolder
void setImagesAssetsFolder(@Nullable() String imageAssetsFolder)
If you use image assets, you must explicitly specify the folder in assets/ in which they arelocated because bodymovin uses the name filenames across all compositions (img_#).Do NOT rename the images themselves.
If your images are located in src/main/assets/airbnb_loader/ then call`setImageAssetsFolder("airbnb_loader/");`.
Be wary if you are using many images, however. Lottie is designed to work with vector shapesfrom After Effects. If your images look like they could be represented with vector shapes,see if it is possible to convert them to shape layers and re-export your animation. Checkthe documentation at airbnb.io/lottie for more information about importing shapes fromSketch or Illustrator to avoid this.
-
getAsyncUpdatesEnabled
boolean getAsyncUpdatesEnabled()
Similar to getAsyncUpdates except it returns the actualboolean value for whether async updates are enabled or not.This is useful when the mode is automatic and you want to knowwhether automatic is defaulting to enabled or not.
-
getPerformanceTracker
@Nullable() PerformanceTracker getPerformanceTracker()
-
setApplyingOpacityToLayersEnabled
void setApplyingOpacityToLayersEnabled(boolean isApplyingOpacityToLayersEnabled)
Sets whether to apply opacity to the each layer instead of shape.
Opacity is normally applied directly to a shape. In cases where translucent shapes overlap, applying opacity to a layer will be more accurateat the expense of performance.
The default value is false.
Note: This process is very expensive. The performance impact will be reduced when hardware acceleration is enabled.
-
disableExtraScaleModeInFitXY
@Deprecated() void disableExtraScaleModeInFitXY()
This API no longer has any effect.
-
clearComposition
void clearComposition()
-
invalidateSelf
void invalidateSelf()
-
setColorFilter
void setColorFilter(@Nullable() ColorFilter colorFilter)
-
getOpacity
int getOpacity()
-
draw
@RestrictTo(value = RestrictTo.Scope.LIBRARY_GROUP) void draw(Canvas canvas, Matrix matrix)
To be used by lottie-compose only.
-
start
@MainThread() void start()
-
stop
@MainThread() void stop()
-
isRunning
boolean isRunning()
-
playAnimation
@MainThread() void playAnimation()
Plays the animation from the beginning. If speed is
{@literal <}0, it will start at the endand play towards the beginning
-
getMarkerForAnimationsDisabled
@RestrictTo(value = RestrictTo.Scope.LIBRARY) Marker getMarkerForAnimationsDisabled()
This method is used to get the marker for animations when system animations are disabled.It iterates over the list of allowed reduced motion markers and returns the first non-null marker it finds.If no non-null marker is found, it returns null.
-
endAnimation
@MainThread() void endAnimation()
-
resumeAnimation
@MainThread() void resumeAnimation()
Continues playing the animation from its current position. If speed
{@literal <}0, it will play backwardsfrom the current position.
-
setMinFrame
void setMinFrame(int minFrame)
Sets the minimum frame that the animation will start from when playing or looping.
-
getMinFrame
float getMinFrame()
Returns the minimum frame set by setMinFrame or setMinProgress
-
setMinProgress
void setMinProgress(float minProgress)
Sets the minimum progress that the animation will start from when playing or looping.
-
setMaxFrame
void setMaxFrame(int maxFrame)
Sets the maximum frame that the animation will end at when playing or looping.
The value will be clamped to the composition bounds. For example, setting Integer.MAX_VALUE would result in the samething as composition.endFrame.
-
getMaxFrame
float getMaxFrame()
Returns the maximum frame set by setMaxFrame or setMaxProgress
-
setMaxProgress
void setMaxProgress(@FloatRange(from = 0f, to = 1f) float maxProgress)
Sets the maximum progress that the animation will end at when playing or looping.
-
setMinFrame
void setMinFrame(String markerName)
Sets the minimum frame to the start time of the specified marker.
-
setMaxFrame
void setMaxFrame(String markerName)
Sets the maximum frame to the start time + duration of the specified marker.
-
setMinAndMaxFrame
void setMinAndMaxFrame(String markerName)
Sets the minimum and maximum frame to the start time and start time + durationof the specified marker.
-
setMinAndMaxFrame
void setMinAndMaxFrame(String startMarkerName, String endMarkerName, boolean playEndMarkerStartFrame)
Sets the minimum and maximum frame to the start marker start and the maximum frame to the end marker start.playEndMarkerStartFrame determines whether or not to play the frame that the end marker is on. If the end markerrepresents the end of the section that you want, it should be true. If the marker represents the beginning of thenext section, it should be false.
-
setMinAndMaxFrame
void setMinAndMaxFrame(int minFrame, int maxFrame)
-
setMinAndMaxProgress
void setMinAndMaxProgress(@FloatRange(from = 0f, to = 1f) float minProgress, @FloatRange(from = 0f, to = 1f) float maxProgress)
-
reverseAnimationSpeed
void reverseAnimationSpeed()
Reverses the current animation speed. This does NOT play the animation.
-
setSpeed
void setSpeed(float speed)
Sets the playback speed. If speed
{@literal <}0, the animation will play backwards.
-
getSpeed
float getSpeed()
Returns the current playback speed. This will be
{@literal <}0 if the animation is playing backwards.
-
addAnimatorUpdateListener
void addAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)
-
removeAnimatorUpdateListener
void removeAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)
-
removeAllUpdateListeners
void removeAllUpdateListeners()
-
addAnimatorListener
void addAnimatorListener(Animator.AnimatorListener listener)
-
removeAnimatorListener
void removeAnimatorListener(Animator.AnimatorListener listener)
-
removeAllAnimatorListeners
void removeAllAnimatorListeners()
-
addAnimatorPauseListener
@RequiresApi(api = Build.VERSION_CODES.KITKAT) void addAnimatorPauseListener(Animator.AnimatorPauseListener listener)
-
removeAnimatorPauseListener
@RequiresApi(api = Build.VERSION_CODES.KITKAT) void removeAnimatorPauseListener(Animator.AnimatorPauseListener listener)
-
setFrame
void setFrame(int frame)
Sets the progress to the specified frame.If the composition isn't set yet, the progress will be set to the frame whenit is.
-
getFrame
int getFrame()
Get the currently rendered frame.
-
setProgress
void setProgress(@FloatRange(from = 0f, to = 1f) float progress)
-
loop
@Deprecated() void loop(boolean loop)
-
setRepeatMode
void setRepeatMode(int mode)
-
getRepeatMode
int getRepeatMode()
Defines what this animation should do when it reaches the end.
-
setRepeatCount
void setRepeatCount(int count)
Sets how many times the animation should be repeated. If the repeatcount is 0, the animation is never repeated. If the repeat count isgreater than 0 or INFINITE, the repeat mode will be takeninto account. The repeat count is 0 by default.
- Parameters:
count- the number of times the animation should be repeated
-
getRepeatCount
int getRepeatCount()
Defines how many times the animation should repeat. The default valueis 0.
-
isLooping
boolean isLooping()
-
isAnimating
boolean isAnimating()
-
animationsEnabled
boolean animationsEnabled(@Nullable() Context context)
-
setSystemAnimationsAreEnabled
@Deprecated() void setSystemAnimationsAreEnabled(Boolean areEnabled)
Tell Lottie that system animations are disabled. When using LottieAnimationView or Compose
{@code LottieAnimation}, this is doneautomatically. However, if you are using LottieDrawable on its own, you should set this to false when getAnimationScale is 0. If the animation is provided a "reduced motion"marker name, they will be shown instead of the first or last frame. Supported marker names are case insensitive, and include:- reduced motion- reducedMotion- reduced_motion- reduced-motion
-
setIgnoreDisabledSystemAnimations
@Deprecated() void setIgnoreDisabledSystemAnimations(boolean ignore)
Allows ignoring system animations settings, therefore allowing animations to run even if they are disabled.
Defaults to false.
- Parameters:
ignore- if true animations will run even when they are disabled in the system settings.
-
setUseCompositionFrameRate
void setUseCompositionFrameRate(boolean useCompositionFrameRate)
Lottie files can specify a target frame rate. By default, Lottie ignores it and re-renderson every frame. If that behavior is undesirable, you can set this to true to use the compositionframe rate instead.
Note: composition frame rates are usually lower than display frame ratesso this will likely make your animation feel janky. However, it may be desirablefor specific situations such as pixel art that are intended to have low frame rates.
-
useTextGlyphs
boolean useTextGlyphs()
-
cancelAnimation
void cancelAnimation()
-
pauseAnimation
void pauseAnimation()
-
getProgress
@FloatRange(from = 0f, to = 1f) float getProgress()
-
getIntrinsicWidth
int getIntrinsicWidth()
-
getIntrinsicHeight
int getIntrinsicHeight()
-
resolveKeyPath
List<KeyPath> resolveKeyPath(KeyPath keyPath)
Takes a KeyPath, potentially with wildcards or globstars and resolve it to a list ofzero or more actual Keypaths that exist in the current animation.
If you want to set value callbacks for any of these values, it is recommend to use thereturned KeyPath objects because they will be internally resolved to their contentand won't trigger a tree walk of the animation contents when applied.
-
addValueCallback
<T> void addValueCallback(KeyPath keyPath, T property, @Nullable() LottieValueCallback<T> callback)
Add an property callback for the specified KeyPath. This KeyPath can resolveto multiple contents. In that case, the callback's value will apply to all of them.
Internally, this will check if the KeyPath has already been resolved with resolveKeyPath and will resolve it if it hasn't.
Set the callback to null to clear it.
-
addValueCallback
<T> void addValueCallback(KeyPath keyPath, T property, SimpleLottieValueCallback<T> callback)
Overload of addValueCallback that takes an interface. This allows you to use a single abstractmethod code block in Kotlin such as:drawable.addValueCallback(yourKeyPath, LottieProperty.COLOR) { yourColor }
-
updateBitmap
@Nullable() Bitmap updateBitmap(String id, @Nullable() Bitmap bitmap)
Allows you to modify or clear a bitmap that was loaded for an image either automaticallythrough setImagesAssetsFolder or with an ImageAssetDelegate.
-
getImageAsset
@Nullable()@Deprecated() Bitmap getImageAsset(String id)
-
getBitmapForId
@Nullable() Bitmap getBitmapForId(String id)
Returns the bitmap that will be rendered for the given id in the Lottie animation file.The id is the asset reference id stored in the "id" property of each object in the "assets" array.
The returned bitmap could be from:* Embedded in the animation file as a base64 string.* In the same directory as the animation file.* In the same zip file as the animation file.* Returned from an ImageAssetDelegate.or null if the image doesn't exist from any of those places.
-
getLottieImageAssetForId
@Nullable() LottieImageAsset getLottieImageAssetForId(String id)
Returns the LottieImageAsset that will be rendered for the given id in the Lottie animation file.The id is the asset reference id stored in the "id" property of each object in the "assets" array.
The returned bitmap could be from:* Embedded in the animation file as a base64 string.* In the same directory as the animation file.* In the same zip file as the animation file.* Returned from an ImageAssetDelegate.or null if the image doesn't exist from any of those places.
-
getTypeface
@Nullable()@RestrictTo(value = RestrictTo.Scope.LIBRARY) Typeface getTypeface(Font font)
-
setVisible
boolean setVisible(boolean visible, boolean restart)
-
invalidateDrawable
void invalidateDrawable(@NonNull() Drawable who)
These Drawable.Callback methods proxy the calls so that this is the drawable that isactually invalidated, not a child one which will not pass the view's validateDrawable check.
-
scheduleDrawable
void scheduleDrawable(@NonNull() Drawable who, @NonNull() Runnable what, long when)
-
unscheduleDrawable
void unscheduleDrawable(@NonNull() Drawable who, @NonNull() Runnable what)
-
-
-
-