-
public class TextDelegateTo replace static text in an animation at runtime, create an instance of this class and call setText to replace the hard coded animation text (input) with the text of your choosing (output).
Alternatively, extend this class and override getText and if the text hasn't already been set by setText then it will call getText.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancacheText
-
Constructor Summary
Constructors Constructor Description TextDelegate(LottieAnimationView animationView)TextDelegate(LottieDrawable drawable)
-
Method Summary
Modifier and Type Method Description voidsetCacheText(boolean cacheText)Sets whether or not TextDelegate will cache (memoize) the results of getText.If this isn't necessary then set it to false. StringgetText(String layerName, String input)Override this to replace the animation text with something dynamic. StringgetText(String input)Override this to replace the animation text with something dynamic. voidsetText(String input, String output)Update the text that will be rendered for the given input text. voidinvalidateText(String input)Invalidates a cached string with the given input. voidinvalidateAllText()Invalidates all cached strings. final StringgetTextInternal(String layerName, String input)-
-
Constructor Detail
-
TextDelegate
TextDelegate(LottieAnimationView animationView)
-
TextDelegate
TextDelegate(LottieDrawable drawable)
-
-
Method Detail
-
setCacheText
void setCacheText(boolean cacheText)
Sets whether or not TextDelegate will cache (memoize) the results of getText.If this isn't necessary then set it to false.
-
getText
String getText(String layerName, String input)
Override this to replace the animation text with something dynamic. This can be used fortranslations or custom data.
- Parameters:
layerName- the name of the layer with textinput- the string at the layer with text
-
getText
String getText(String input)
Override this to replace the animation text with something dynamic. This can be used fortranslations or custom data.
-
setText
void setText(String input, String output)
Update the text that will be rendered for the given input text.
-
invalidateText
void invalidateText(String input)
Invalidates a cached string with the given input.
-
invalidateAllText
void invalidateAllText()
Invalidates all cached strings.
-
getTextInternal
@RestrictTo(value = RestrictTo.Scope.LIBRARY) final String getTextInternal(String layerName, String input)
-
-
-
-