Found in sources of lottie, based on main answer (thanks @SolveSoul ).
Java
First, get your color, for example:
int yourColor = ContextCompat.getColor(getContext(),R.color.colorPrimary);
Then set color filter like this:
SimpleColorFilter filter = new SimpleColorFilter(yourColor);
KeyPath keyPath = new KeyPath("**");
LottieValueCallback<ColorFilter> callback = new LottieValueCallback<ColorFilter>(filter);
animationView.addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback);
Kotlin
First, get your color, for example:
val yourColor = ContextCompat.getColor(context, R.color.colorPrimary)
Then set color filter like this:
val filter = SimpleColorFilter(yourColor)
val keyPath = KeyPath("**")
val callback: LottieValueCallback<ColorFilter> = LottieValueCallback(filter)
animationView.addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback)
Kotlin extension
fun LottieAnimationView.changeLayersColor(
@ColorRes colorRes: Int
) {
val color = ContextCompat.getColor(context, colorRes)
val filter = SimpleColorFilter(color)
val keyPath = KeyPath("**")
val callback: LottieValueCallback<ColorFilter> = LottieValueCallback(filter)
addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback)
}