public class LottieAnimationView
extends AppCompatImageView
You may set the animation in one of two ways:
1) Attrs: R.styleable#LottieAnimationView_lottie_fileName
2) Programatically: setAnimation(String), setComposition(LottieComposition),
or setAnimation(JSONObject).
You can set a default cache strategy with R.attr#lottie_cacheStrategy.
You can manually set the progress of the animation with setProgress(float) or
R.attr#lottie_progress
| Modifier and Type | Class and Description |
|---|---|
static class |
LottieAnimationView.CacheStrategy
Caching strategy for compositions that will be reused frequently.
|
| Constructor and Description |
|---|
LottieAnimationView(android.content.Context context) |
LottieAnimationView(android.content.Context context,
android.util.AttributeSet attrs) |
LottieAnimationView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAnimatorListener(android.animation.Animator.AnimatorListener listener) |
void |
addAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener) |
void |
cancelAnimation() |
void |
enableMergePathsForKitKatAndAbove(boolean enable)
Enable this to get merge path support for devices running KitKat (19) and above.
|
long |
getDuration() |
float |
getProgress() |
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 dr) |
boolean |
isAnimating() |
void |
loop(boolean loop) |
protected void |
onAttachedToWindow() |
protected void |
onDetachedFromWindow() |
protected void |
onRestoreInstanceState(android.os.Parcelable state) |
protected android.os.Parcelable |
onSaveInstanceState() |
void |
pauseAnimation() |
void |
playAnimation() |
void |
removeAnimatorListener(android.animation.Animator.AnimatorListener listener) |
void |
removeUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener) |
void |
resumeAnimation() |
void |
resumeReverseAnimation() |
void |
reverseAnimation() |
void |
setAnimation(org.json.JSONObject json)
Sets the animation from a JSONObject.
|
void |
setAnimation(java.lang.String animationName)
Sets the animation from a file in the assets directory.
|
void |
setAnimation(java.lang.String animationName,
LottieAnimationView.CacheStrategy cacheStrategy)
Sets the animation from a file in the assets directory.
|
void |
setComposition(LottieComposition composition)
Sets a composition.
|
void |
setImageAssetDelegate(ImageAssetDelegate assetDelegate)
Use this if you can't bundle images with your app.
|
void |
setImageAssetsFolder(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 |
setImageDrawable(android.graphics.drawable.Drawable drawable) |
void |
setImageResource(int resId) |
void |
setProgress(float progress) |
void |
setSpeed(float speed) |
void |
useExperimentalHardwareAcceleration()
Enable hardware acceleration for this view.
|
public LottieAnimationView(android.content.Context context)
public LottieAnimationView(android.content.Context context,
android.util.AttributeSet attrs)
public LottieAnimationView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
public void setImageResource(int resId)
public void setImageDrawable(android.graphics.drawable.Drawable drawable)
public void invalidateDrawable(android.graphics.drawable.Drawable dr)
protected android.os.Parcelable onSaveInstanceState()
protected void onRestoreInstanceState(android.os.Parcelable state)
protected void onAttachedToWindow()
protected void onDetachedFromWindow()
public void enableMergePathsForKitKatAndAbove(boolean enable)
public void useExperimentalHardwareAcceleration()
public void setAnimation(java.lang.String animationName)
Will not cache the composition once loaded.
public void setAnimation(java.lang.String animationName,
LottieAnimationView.CacheStrategy cacheStrategy)
You may also specify a cache strategy. Specifying LottieAnimationView.CacheStrategy.Strong will hold a
strong reference to the composition once it is loaded
and deserialized. LottieAnimationView.CacheStrategy.Weak will hold a weak reference to said composition.
public void setAnimation(org.json.JSONObject json)
This is particularly useful for animations loaded from the network. You can fetch the bodymovin json from the network and pass it directly here.
public void setComposition(LottieComposition composition)
R.attr#lottie_cacheStrategy.public boolean hasMasks()
public boolean hasMatte()
public void setImageAssetsFolder(java.lang.String imageAssetsFolder)
public void addAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener)
public void removeUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener updateListener)
public void addAnimatorListener(android.animation.Animator.AnimatorListener listener)
public void removeAnimatorListener(android.animation.Animator.AnimatorListener listener)
public void loop(boolean loop)
public boolean isAnimating()
public void playAnimation()
public void resumeAnimation()
public void reverseAnimation()
public void resumeReverseAnimation()
public void setSpeed(float speed)
public void setImageAssetDelegate(ImageAssetDelegate assetDelegate)
public void cancelAnimation()
public void pauseAnimation()
public void setProgress(float progress)
public float getProgress()
public long getDuration()