Class LottieAnimationView
- java.lang.Object
-
- android.view.View
-
- android.widget.ImageView
-
- androidx.appcompat.widget.AppCompatImageView
-
- com.airbnb.lottie.LottieAnimationView
-
- All Implemented Interfaces:
Drawable.Callback,AccessibilityEventSource,KeyEvent.Callback,androidx.core.view.TintableBackgroundView,androidx.core.widget.TintableImageSourceView
public class LottieAnimationView extends androidx.appcompat.widget.AppCompatImageViewThis view will load, deserialize, and display an After Effects animation exported with bodymovin (https://github.com/bodymovin/bodymovin).You may set the animation in one of two ways: 1) Attrs:
R.styleable.LottieAnimationView_lottie_fileName2) Programmatically:setAnimation(String)setAnimation(int)setAnimation(InputStream, String)setAnimationFromJson(String, String)setAnimationFromUrl(String)setComposition(LottieComposition)You can set a default cache strategy with
R.attr.lottie_cacheComposition.You can manually set the progress of the animation with
setProgress(float)orR.attr.lottie_progress- See Also:
- Full Documentation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class android.widget.ImageView
ImageView.ScaleType
-
Nested classes/interfaces inherited from class android.view.View
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.MeasureSpec, View.OnApplyWindowInsetsListener, View.OnAttachStateChangeListener, View.OnCapturedPointerListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.OnUnhandledKeyEventListener
-
-
Field Summary
-
Fields inherited from class android.view.View
ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_USERNAME, AUTOFILL_TYPE_DATE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_NONE, AUTOFILL_TYPE_TEXT, AUTOFILL_TYPE_TOGGLE, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, IMPORTANT_FOR_AUTOFILL_AUTO, IMPORTANT_FOR_AUTOFILL_NO, IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_AUTOFILL_YES, IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_CONTENT_CAPTURE_AUTO, IMPORTANT_FOR_CONTENT_CAPTURE_NO, IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_CONTENT_CAPTURE_YES, IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
-
-
Constructor Summary
Constructors Constructor Description LottieAnimationView(Context context)LottieAnimationView(Context context, AttributeSet attrs)LottieAnimationView(Context context, AttributeSet attrs, int defStyleAttr)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAnimatorListener(Animator.AnimatorListener listener)voidaddAnimatorPauseListener(Animator.AnimatorPauseListener listener)voidaddAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)booleanaddLottieOnCompositionLoadedListener(LottieOnCompositionLoadedListener lottieOnCompositionLoadedListener)<T> voidaddValueCallback(KeyPath keyPath, T property, LottieValueCallback<T> callback)Add a property callback for the specifiedKeyPath.<T> voidaddValueCallback(KeyPath keyPath, T property, SimpleLottieValueCallback<T> callback)Overload ofaddValueCallback(KeyPath, Object, LottieValueCallback)that takes an interface.voidbuildDrawingCache(boolean autoScale)If rendering via software, Android will fail to generate a bitmap if the view is too large.voidcancelAnimation()voiddisableExtraScaleModeInFitXY()Disable the extraScale mode inView.draw(Canvas)function when scaleType is FitXY.voidenableMergePathsForKitKatAndAbove(boolean enable)Enable this to get merge path support for devices running KitKat (19) and above.LottieCompositiongetComposition()longgetDuration()intgetFrame()Get the currently rendered frame.java.lang.StringgetImageAssetsFolder()floatgetMaxFrame()Returns the maximum frame set bysetMaxFrame(int)orsetMaxProgress(float)floatgetMinFrame()Returns the minimum frame set bysetMinFrame(int)orsetMinProgress(float)PerformanceTrackergetPerformanceTracker()floatgetProgress()intgetRepeatCount()Defines how many times the animation should repeat.intgetRepeatMode()Defines what this animation should do when it reaches the end.floatgetScale()floatgetSpeed()Returns the current playback speed.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.voidinvalidateDrawable(Drawable dr)booleanisAnimating()booleanisMergePathsEnabledForKitKatAndAbove()Returns whether merge paths are enabled for KitKat and above.voidloop(boolean loop)Deprecated.protected voidonAttachedToWindow()protected voidonDetachedFromWindow()protected voidonRestoreInstanceState(Parcelable state)protected ParcelableonSaveInstanceState()protected voidonVisibilityChanged(View changedView, int visibility)voidpauseAnimation()voidplayAnimation()Plays the animation from the beginning.voidremoveAllAnimatorListeners()voidremoveAllLottieOnCompositionLoadedListener()voidremoveAllUpdateListeners()voidremoveAnimatorListener(Animator.AnimatorListener listener)voidremoveAnimatorPauseListener(Animator.AnimatorPauseListener listener)booleanremoveLottieOnCompositionLoadedListener(LottieOnCompositionLoadedListener lottieOnCompositionLoadedListener)voidremoveUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)java.util.List<KeyPath>resolveKeyPath(KeyPath keyPath)voidresumeAnimation()Continues playing the animation from its current position.voidreverseAnimationSpeed()Reverses the current animation speed.voidsetAnimation(int rawRes)Sets the animation from a file in the raw directory.voidsetAnimation(java.io.InputStream stream, java.lang.String cacheKey)Sets the animation from an arbitrary InputStream.voidsetAnimation(java.lang.String assetName)voidsetAnimationFromJson(java.lang.String jsonString)Deprecated.voidsetAnimationFromJson(java.lang.String jsonString, java.lang.String cacheKey)Sets the animation from json string.voidsetAnimationFromUrl(java.lang.String url)Load a lottie animation from a url.voidsetAnimationFromUrl(java.lang.String url, java.lang.String cacheKey)Load a lottie animation from a url.voidsetApplyingOpacityToLayersEnabled(boolean isApplyingOpacityToLayersEnabled)Sets whether to apply opacity to the each layer instead of shape.voidsetCacheComposition(boolean cacheComposition)If set to true, all future compositions that are set will be cached so that they don't need to be parsed next time they are loaded.voidsetComposition(LottieComposition composition)Sets a composition.voidsetFailureListener(LottieListener<java.lang.Throwable> failureListener)Set a default failure listener that will be called if any of the setAnimation APIs fail for any reason.voidsetFallbackResource(int fallbackResource)Set a drawable that will be rendered if the LottieComposition fails to load for any reason.voidsetFontAssetDelegate(FontAssetDelegate assetDelegate)Use this to manually set fonts.voidsetFrame(int frame)Sets the progress to the specified frame.voidsetImageAssetDelegate(ImageAssetDelegate assetDelegate)Use this if you can't bundle images with your app.voidsetImageAssetsFolder(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_#).voidsetImageBitmap(Bitmap bm)voidsetImageDrawable(Drawable drawable)voidsetImageResource(int resId)voidsetMaxFrame(int endFrame)Sets the maximum frame that the animation will end at when playing or looping.voidsetMaxFrame(java.lang.String markerName)Sets the maximum frame to the start time + duration of the specified marker.voidsetMaxProgress(float endProgress)Sets the maximum progress that the animation will end at when playing or looping.voidsetMinAndMaxFrame(int minFrame, int maxFrame)voidsetMinAndMaxFrame(java.lang.String markerName)Sets the minimum and maximum frame to the start time and start time + duration of the specified marker.voidsetMinAndMaxFrame(java.lang.String startMarkerName, java.lang.String endMarkerName, boolean playEndMarkerStartFrame)Sets the minimum and maximum frame to the start marker start and the maximum frame to the end marker start.voidsetMinAndMaxProgress(float minProgress, float maxProgress)voidsetMinFrame(int startFrame)Sets the minimum frame that the animation will start from when playing or looping.voidsetMinFrame(java.lang.String markerName)Sets the minimum frame to the start time of the specified marker.voidsetMinProgress(float startProgress)Sets the minimum progress that the animation will start from when playing or looping.voidsetOutlineMasksAndMattes(boolean outline)Enable this to debug slow animations by outlining masks and mattes.voidsetPerformanceTrackingEnabled(boolean enabled)voidsetProgress(float progress)voidsetRenderMode(RenderMode renderMode)Call this to set whether or not to render with hardware or software acceleration.voidsetRepeatCount(int count)Sets how many times the animation should be repeated.voidsetRepeatMode(int mode)Defines what this animation should do when it reaches the end.voidsetSafeMode(boolean safeMode)If you are experiencing a device specific crash that happens during drawing, you can set this to true for those devices.voidsetScale(float scale)Set the scale on the current composition.voidsetSpeed(float speed)Sets the playback speed.voidsetTextDelegate(TextDelegate textDelegate)Set this to replace animation text with custom text at runtimevoidunscheduleDrawable(Drawable who)BitmapupdateBitmap(java.lang.String id, Bitmap bitmap)Allows you to modify or clear a bitmap that was loaded for an image either automatically throughsetImageAssetsFolder(String)or with anImageAssetDelegate.-
Methods inherited from class androidx.appcompat.widget.AppCompatImageView
drawableStateChanged, getSupportBackgroundTintList, getSupportBackgroundTintMode, getSupportImageTintList, getSupportImageTintMode, hasOverlappingRendering, setBackgroundDrawable, setBackgroundResource, setImageURI, setSupportBackgroundTintList, setSupportBackgroundTintMode, setSupportImageTintList, setSupportImageTintMode
-
Methods inherited from class android.widget.ImageView
animateTransform, clearColorFilter, drawableHotspotChanged, getAccessibilityClassName, getAdjustViewBounds, getBaseline, getBaselineAlignBottom, getColorFilter, getCropToPadding, getDrawable, getImageAlpha, getImageMatrix, getImageTintBlendMode, getImageTintList, getImageTintMode, getMaxHeight, getMaxWidth, getScaleType, isOpaque, jumpDrawablesToCurrentState, onCreateDrawableState, onDraw, onMeasure, onRtlPropertiesChanged, onVisibilityAggregated, setAdjustViewBounds, setAlpha, setBaseline, setBaselineAlignBottom, setColorFilter, setColorFilter, setColorFilter, setCropToPadding, setFrame, setImageAlpha, setImageIcon, setImageLevel, setImageMatrix, setImageState, setImageTintBlendMode, setImageTintList, setImageTintMode, setMaxHeight, setMaxWidth, setScaleType, setSelected, setVisibility, verifyDrawable
-
Methods inherited from class android.view.View
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addFocusables, addKeyboardNavigationClusters, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, addTouchables, animate, announceForAccessibility, autofill, autofill, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerCaptureChanged, dispatchPopulateAccessibilityEvent, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, findFocus, findViewById, findViewsWithText, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getContextMenuInfo, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverlay, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocus, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasPointerCapture, hasTransientState, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onResolvePointerIcon, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreDefaultFocus, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setWillNotCacheDrawing, setWillNotDraw, setWindowInsetsAnimationCallback, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, updateDragShadow, willNotCacheDrawing, willNotDraw
-
-
-
-
Constructor Detail
-
LottieAnimationView
public LottieAnimationView(Context context)
-
LottieAnimationView
public LottieAnimationView(Context context, AttributeSet attrs)
-
LottieAnimationView
public LottieAnimationView(Context context, AttributeSet attrs, int defStyleAttr)
-
-
Method Detail
-
setImageResource
public void setImageResource(int resId)
- Overrides:
setImageResourcein classandroidx.appcompat.widget.AppCompatImageView
-
setImageDrawable
public void setImageDrawable(Drawable drawable)
- Overrides:
setImageDrawablein classandroidx.appcompat.widget.AppCompatImageView
-
setImageBitmap
public void setImageBitmap(Bitmap bm)
- Overrides:
setImageBitmapin classandroidx.appcompat.widget.AppCompatImageView
-
unscheduleDrawable
public void unscheduleDrawable(Drawable who)
- Overrides:
unscheduleDrawablein classView
-
invalidateDrawable
public void invalidateDrawable(@NonNull Drawable dr)- Specified by:
invalidateDrawablein interfaceDrawable.Callback- Overrides:
invalidateDrawablein classImageView
-
onSaveInstanceState
protected Parcelable onSaveInstanceState()
- Overrides:
onSaveInstanceStatein classView
-
onRestoreInstanceState
protected void onRestoreInstanceState(Parcelable state)
- Overrides:
onRestoreInstanceStatein classView
-
onVisibilityChanged
protected void onVisibilityChanged(@NonNull View changedView, int visibility)- Overrides:
onVisibilityChangedin classView
-
onAttachedToWindow
protected void onAttachedToWindow()
- Overrides:
onAttachedToWindowin classImageView
-
onDetachedFromWindow
protected void onDetachedFromWindow()
- Overrides:
onDetachedFromWindowin classImageView
-
enableMergePathsForKitKatAndAbove
public void enableMergePathsForKitKatAndAbove(boolean enable)
Enable this to get merge path support for devices running KitKat (19) and above. Merge paths currently don't work if the the operand shape is entirely contained within the first shape. If you need to cut out one shape from another shape, use an even-odd fill type instead of using merge paths.
-
isMergePathsEnabledForKitKatAndAbove
public boolean isMergePathsEnabledForKitKatAndAbove()
Returns whether merge paths are enabled for KitKat and above.
-
setCacheComposition
public void setCacheComposition(boolean cacheComposition)
If set to true, all future compositions that are set will be cached so that they don't need to be parsed next time they are loaded. This won't apply to compositions that have already been loaded. Defaults to true.R.attr.lottie_cacheComposition
-
setOutlineMasksAndMattes
public void setOutlineMasksAndMattes(boolean outline)
Enable this to debug slow animations by outlining masks and mattes. The performance overhead of the masks and mattes will be proportional to the surface area of all of the masks/mattes combined. DO NOT leave this enabled in production.
-
setAnimation
public void setAnimation(@RawRes int rawRes)Sets the animation from a file in the raw directory. This will load and deserialize the file asynchronously.
-
setAnimation
public void setAnimation(java.lang.String assetName)
-
setAnimationFromJson
@Deprecated public void setAnimationFromJson(java.lang.String jsonString)
Deprecated.- See Also:
setAnimationFromJson(String, String)
-
setAnimationFromJson
public void setAnimationFromJson(java.lang.String jsonString, @Nullable java.lang.String cacheKey)Sets the animation from json string. This is the ideal API to use when loading an animation over the network because you can use the raw response body here and a conversion to a JSONObject never has to be done.
-
setAnimation
public void setAnimation(java.io.InputStream stream, @Nullable java.lang.String cacheKey)Sets the animation from an arbitrary InputStream. This will load and deserialize the file asynchronously.This is particularly useful for animations loaded from the network. You can fetch the bodymovin json from the network and pass it directly here.
-
setAnimationFromUrl
public void setAnimationFromUrl(java.lang.String url)
Load a lottie animation from a url. The url can be a json file or a zip file. Use a zip file if you have images. Simply zip them together and lottie will unzip and link the images automatically. Under the hood, Lottie uses Java HttpURLConnection because it doesn't require any transitive networking dependencies. It will download the file to the application cache under a temporary name. If the file successfully parses to a composition, it will rename the temporary file to one that can be accessed immediately for subsequent requests. If the file does not parse to a composition, the temporary file will be deleted. You can replace the default network stack or cache handling with a globalLottieConfig
-
setAnimationFromUrl
public void setAnimationFromUrl(java.lang.String url, @Nullable java.lang.String cacheKey)Load a lottie animation from a url. The url can be a json file or a zip file. Use a zip file if you have images. Simply zip them together and lottie will unzip and link the images automatically. Under the hood, Lottie uses Java HttpURLConnection because it doesn't require any transitive networking dependencies. It will download the file to the application cache under a temporary name. If the file successfully parses to a composition, it will rename the temporary file to one that can be accessed immediately for subsequent requests. If the file does not parse to a composition, the temporary file will be deleted. You can replace the default network stack or cache handling with a globalLottieConfig
-
setFailureListener
public void setFailureListener(@Nullable LottieListener<java.lang.Throwable> failureListener)Set a default failure listener that will be called if any of the setAnimation APIs fail for any reason. This can be used to replace the default behavior. The default behavior will log any network errors and rethrow all other exceptions. If you are loading an animation from the network, errors may occur if your user has no internet. You can use this listener to retry the download or you can have it default to an error drawable withsetFallbackResource(int). Unless you are usingsetAnimationFromUrl(String), errors are unexpected. Set the listener to null to revert to the default behavior.
-
setFallbackResource
public void setFallbackResource(@DrawableRes int fallbackResource)Set a drawable that will be rendered if the LottieComposition fails to load for any reason. Unless you are usingsetAnimationFromUrl(String), this is an unexpected error and you should handle it withsetFailureListener(LottieListener). If this is a network animation, you may use this to show an error to the user or you can use a failure listener to retry the download.
-
setComposition
public void setComposition(@NonNull LottieComposition composition)Sets a composition. You can set a default cache strategy if this view was inflated with xml by usingR.attr.lottie_cacheComposition.
-
getComposition
@Nullable public LottieComposition getComposition()
-
hasMasks
public boolean hasMasks()
Returns whether or not any layers in this composition has masks.
-
hasMatte
public boolean hasMatte()
Returns whether or not any layers in this composition has a matte layer.
-
playAnimation
@MainThread public void playAnimation()
Plays the animation from the beginning. If speed is < 0, it will start at the end and play towards the beginning
-
resumeAnimation
@MainThread public void resumeAnimation()
Continues playing the animation from its current position. If speed < 0, it will play backwards from the current position.
-
setMinFrame
public void setMinFrame(int startFrame)
Sets the minimum frame that the animation will start from when playing or looping.
-
getMinFrame
public float getMinFrame()
Returns the minimum frame set bysetMinFrame(int)orsetMinProgress(float)
-
setMinProgress
public void setMinProgress(float startProgress)
Sets the minimum progress that the animation will start from when playing or looping.
-
setMaxFrame
public void setMaxFrame(int endFrame)
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 same thing as composition.endFrame.
-
getMaxFrame
public float getMaxFrame()
Returns the maximum frame set bysetMaxFrame(int)orsetMaxProgress(float)
-
setMaxProgress
public void setMaxProgress(float endProgress)
Sets the maximum progress that the animation will end at when playing or looping.
-
setMinFrame
public void setMinFrame(java.lang.String markerName)
Sets the minimum frame to the start time of the specified marker.- Throws:
java.lang.IllegalArgumentException- if the marker is not found.
-
setMaxFrame
public void setMaxFrame(java.lang.String markerName)
Sets the maximum frame to the start time + duration of the specified marker.- Throws:
java.lang.IllegalArgumentException- if the marker is not found.
-
setMinAndMaxFrame
public void setMinAndMaxFrame(java.lang.String markerName)
Sets the minimum and maximum frame to the start time and start time + duration of the specified marker.- Throws:
java.lang.IllegalArgumentException- if the marker is not found.
-
setMinAndMaxFrame
public void setMinAndMaxFrame(java.lang.String startMarkerName, java.lang.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 marker represents the end of the section that you want, it should be true. If the marker represents the beginning of the next section, it should be false.- Throws:
java.lang.IllegalArgumentException- if either marker is not found.
-
setMinAndMaxFrame
public void setMinAndMaxFrame(int minFrame, int maxFrame)- See Also:
setMinFrame(int),setMaxFrame(int)
-
setMinAndMaxProgress
public void setMinAndMaxProgress(float minProgress, float maxProgress)- See Also:
setMinProgress(float),setMaxProgress(float)
-
reverseAnimationSpeed
public void reverseAnimationSpeed()
Reverses the current animation speed. This does NOT play the animation.- See Also:
setSpeed(float),playAnimation(),resumeAnimation()
-
setSpeed
public void setSpeed(float speed)
Sets the playback speed. If speed < 0, the animation will play backwards.
-
getSpeed
public float getSpeed()
Returns the current playback speed. This will be < 0 if the animation is playing backwards.
-
addAnimatorUpdateListener
public void addAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)
-
removeUpdateListener
public void removeUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener)
-
removeAllUpdateListeners
public void removeAllUpdateListeners()
-
addAnimatorListener
public void addAnimatorListener(Animator.AnimatorListener listener)
-
removeAnimatorListener
public void removeAnimatorListener(Animator.AnimatorListener listener)
-
removeAllAnimatorListeners
public void removeAllAnimatorListeners()
-
addAnimatorPauseListener
public void addAnimatorPauseListener(Animator.AnimatorPauseListener listener)
-
removeAnimatorPauseListener
public void removeAnimatorPauseListener(Animator.AnimatorPauseListener listener)
-
loop
@Deprecated public void loop(boolean loop)
Deprecated.- See Also:
setRepeatCount(int)
-
setRepeatMode
public void setRepeatMode(int mode)
Defines what this animation should do when it reaches the end. This setting is applied only when the repeat count is either greater than 0 orLottieDrawable.INFINITE. Defaults toLottieDrawable.RESTART.- Parameters:
mode-LottieDrawable.RESTARTorLottieDrawable.REVERSE
-
getRepeatMode
public int getRepeatMode()
Defines what this animation should do when it reaches the end.- Returns:
- either one of
LottieDrawable.REVERSEorLottieDrawable.RESTART
-
setRepeatCount
public void setRepeatCount(int count)
Sets how many times the animation should be repeated. If the repeat count is 0, the animation is never repeated. If the repeat count is greater than 0 orLottieDrawable.INFINITE, the repeat mode will be taken into account. The repeat count is 0 by default.- Parameters:
count- the number of times the animation should be repeated
-
getRepeatCount
public int getRepeatCount()
Defines how many times the animation should repeat. The default value is 0.- Returns:
- the number of times the animation should repeat, or
LottieDrawable.INFINITE
-
isAnimating
public boolean isAnimating()
-
setImageAssetsFolder
public 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_#). 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 shapes from 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. Check the documentation at http://airbnb.io/lottie for more information about importing shapes from Sketch or Illustrator to avoid this.
-
getImageAssetsFolder
@Nullable public java.lang.String getImageAssetsFolder()
-
updateBitmap
@Nullable public Bitmap updateBitmap(java.lang.String id, @Nullable Bitmap bitmap)
Allows you to modify or clear a bitmap that was loaded for an image either automatically throughsetImageAssetsFolder(String)or with anImageAssetDelegate.- Returns:
- the previous Bitmap or null.
-
setImageAssetDelegate
public void setImageAssetDelegate(ImageAssetDelegate assetDelegate)
Use this if you can't bundle images with your app. This may be useful if you download the animations from the network or have the images saved to an SD Card. In that case, Lottie will 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 shapes from 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. Check the documentation at http://airbnb.io/lottie for more information about importing shapes from Sketch or Illustrator to avoid this.
-
setFontAssetDelegate
public void setFontAssetDelegate(FontAssetDelegate assetDelegate)
Use this to manually set fonts.
-
setTextDelegate
public void setTextDelegate(TextDelegate textDelegate)
Set this to replace animation text with custom text at runtime
-
resolveKeyPath
public java.util.List<KeyPath> resolveKeyPath(KeyPath keyPath)
Takes aKeyPath, potentially with wildcards or globstars and resolve it to a list of zero or more actualKeypathsthat exist in the current animation. If you want to set value callbacks for any of these values, it is recommended to use the returnedKeyPathobjects because they will be internally resolved to their content and won't trigger a tree walk of the animation contents when applied.
-
addValueCallback
public <T> void addValueCallback(KeyPath keyPath, T property, LottieValueCallback<T> callback)
Add a property callback for the specifiedKeyPath. ThisKeyPathcan resolve to multiple contents. In that case, the callback's value will apply to all of them. Internally, this will check if theKeyPathhas already been resolved withresolveKeyPath(KeyPath)and will resolve it if it hasn't.
-
addValueCallback
public <T> void addValueCallback(KeyPath keyPath, T property, SimpleLottieValueCallback<T> callback)
Overload ofaddValueCallback(KeyPath, Object, LottieValueCallback)that takes an interface. This allows you to use a single abstract method code block in Kotlin such as: animationView.addValueCallback(yourKeyPath, LottieProperty.COLOR) { yourColor }
-
setScale
public void setScale(float scale)
Set the scale on the current composition. The only cost of this function is re-rendering the current frame so you may call it frequent to scale something up or down. The smaller the animation is, the better the performance will be. You may find that scaling an animation down then rendering it in a larger ImageView and letting ImageView scale it back up with a scaleType such as centerInside will yield better performance with little perceivable quality loss. You can also use a fixed view width/height in conjunction with the normal ImageView scaleTypes centerCrop and centerInside.
-
getScale
public float getScale()
-
cancelAnimation
@MainThread public void cancelAnimation()
-
pauseAnimation
@MainThread public void pauseAnimation()
-
setFrame
public 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 when it is.
-
getFrame
public int getFrame()
Get the currently rendered frame.
-
setProgress
public void setProgress(float progress)
-
getProgress
public float getProgress()
-
getDuration
public long getDuration()
-
setPerformanceTrackingEnabled
public void setPerformanceTrackingEnabled(boolean enabled)
-
getPerformanceTracker
@Nullable public PerformanceTracker getPerformanceTracker()
-
setSafeMode
public void setSafeMode(boolean safeMode)
If you are experiencing a device specific crash that happens during drawing, you can set this to true for those devices. If set to true, draw will be wrapped with a try/catch which will cause Lottie to render 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 use this for very specific cases if absolutely necessary. There is no XML attr for this because it should be set programmatically and only for specific devices that are known to be problematic.
-
buildDrawingCache
public void buildDrawingCache(boolean autoScale)
If rendering via software, Android will fail to generate a bitmap if the view is too large. Rather than displaying nothing, fallback on hardware acceleration which may incur a performance hit.- Overrides:
buildDrawingCachein classView- See Also:
setRenderMode(RenderMode),LottieDrawable.draw(android.graphics.Canvas)
-
setRenderMode
public 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 unless there are many large mattes and masks in which case there is a ton of 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) then you should test both render modes. You should also test on pre-Pie and Pie+ devices because the underlying rendering enginge changed significantly.
-
setApplyingOpacityToLayersEnabled
public 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 accurate at 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.
- See Also:
setRenderMode(RenderMode)
-
disableExtraScaleModeInFitXY
public void disableExtraScaleModeInFitXY()
Disable the extraScale mode inView.draw(Canvas)function when scaleType is FitXY. It doesn't affect the rendering with other scaleTypes.When there are 2 animation layout side by side, the default extra scale mode might leave 1 pixel not drawn between 2 animation, and disabling the extraScale mode can fix this problem
Attention: Disable the extra scale mode can downgrade the performance and may lead to larger memory footprint. Please only disable this mode when using animation with a reasonable dimension (smaller than screen size).
-
addLottieOnCompositionLoadedListener
public boolean addLottieOnCompositionLoadedListener(@NonNull LottieOnCompositionLoadedListener lottieOnCompositionLoadedListener)
-
removeLottieOnCompositionLoadedListener
public boolean removeLottieOnCompositionLoadedListener(@NonNull LottieOnCompositionLoadedListener lottieOnCompositionLoadedListener)
-
removeAllLottieOnCompositionLoadedListener
public void removeAllLottieOnCompositionLoadedListener()
-
-