I realise this is an old question, but since I too came against the same problem and managed to find how to do it, might as well share it.
So a LottieCompositionFactory
can be used to obtain a LottieComposition
from a raw
.json
file, URL, or assets in the assets
folder etc. using the corresponding function as given in the API reference, and then use the composition to assign it to a LottieDrawable
.
For example, using a .json
file
val animDrawable = LottieDrawable()
LottieCompositionFactory.fromRawRes(requireContext(), R.raw.anim_file).addListener {comp ->
animDrawable.composition = comp
}
Then the drawable can be used anywhere a Drawable
can be passed.