Skip to content

Commit af275e4

Browse files
committed
fix: use color filter to set color on android
1 parent b57a64b commit af275e4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/lottie.android.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import {
1717
} from './lottie.common';
1818
import { clamp } from './utils';
1919

20-
let LottieProperty;
21-
let LottieKeyPath;
22-
let LottieValueCallback;
20+
let LottieProperty: typeof com.airbnb.lottie.LottieProperty;
21+
let LottieKeyPath: typeof com.airbnb.lottie.model.KeyPath;
22+
let LottieValueCallback: typeof com.airbnb.lottie.value.LottieValueCallback;
2323

2424
const cache = new Map();
2525
function loadLottieJSON(iconSrc) {
@@ -190,10 +190,12 @@ export class LottieView extends LottieViewBase {
190190
if (!LottieKeyPath) {
191191
LottieKeyPath = com.airbnb.lottie.model.KeyPath;
192192
}
193+
// by using color filter we change all colors (STROKE_COLOR and COLOR)
194+
const colorFilter = new com.airbnb.lottie.SimpleColorFilter(value.android);
193195
this.nativeViewProtected.addValueCallback(
194-
new LottieKeyPath(nativeKeyPath),
195-
LottieProperty.COLOR,
196-
new LottieValueCallback(new java.lang.Integer(value.android))
196+
new LottieKeyPath(nativeKeyPath as any),
197+
LottieProperty.COLOR_FILTER,
198+
new LottieValueCallback(colorFilter)
197199
);
198200
}
199201
}
@@ -222,7 +224,7 @@ export class LottieView extends LottieViewBase {
222224
LottieKeyPath = com.airbnb.lottie.model.KeyPath;
223225
}
224226
this.nativeViewProtected.addValueCallback(
225-
new LottieKeyPath(nativeKeyPath),
227+
new LottieKeyPath(nativeKeyPath as any),
226228
LottieProperty.OPACITY,
227229
new LottieValueCallback(new java.lang.Integer(value * 100))
228230
);

0 commit comments

Comments
 (0)