Package com.airbnb.lottie
Class TextDelegate
- java.lang.Object
-
- com.airbnb.lottie.TextDelegate
-
public class TextDelegate extends Object
To replace static text in an animation at runtime, create an instance of this class and callsetText(String, String)to replace the hard coded animation text (input) with the text of your choosing (output).Alternatively, extend this class and override
getText(String)and if the text hasn't already been set bysetText(String, String)then it will callgetText(String).
-
-
Constructor Summary
Constructors Constructor Description TextDelegate(LottieAnimationView animationView)TextDelegate(LottieDrawable drawable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetText(String input)Override this to replace the animation text with something dynamic.StringgetText(String layerName, String input)Override this to replace the animation text with something dynamic.StringgetTextInternal(String layerName, String input)voidinvalidateAllText()Invalidates all cached strings.voidinvalidateText(String input)Invalidates a cached string with the given input.voidsetCacheText(boolean cacheText)Sets whether or notTextDelegatewill cache (memoize) the results of getText.voidsetText(String input, String output)Update the text that will be rendered for the given input text.
-
-
-
Constructor Detail
-
TextDelegate
public TextDelegate(LottieAnimationView animationView)
-
TextDelegate
public TextDelegate(LottieDrawable drawable)
-
-
Method Detail
-
getText
public String getText(String layerName, String input)
Override this to replace the animation text with something dynamic. This can be used for translations or custom data.- Parameters:
layerName- the name of the layer with textinput- the string at the layer with text- Returns:
- a String to use for the specific data, by default this is the same as getText(input)
-
getText
public String getText(String input)
Override this to replace the animation text with something dynamic. This can be used for translations or custom data.
-
setText
public void setText(String input, String output)
Update the text that will be rendered for the given input text.
-
setCacheText
public void setCacheText(boolean cacheText)
Sets whether or notTextDelegatewill cache (memoize) the results of getText. If this isn't necessary then set it to false.
-
invalidateText
public void invalidateText(String input)
Invalidates a cached string with the given input.
-
invalidateAllText
public void invalidateAllText()
Invalidates all cached strings.
-
-