mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
fix: android ActivityIndicator custom color affecting other indicators on the page (#9026)
* fix(core): Setting color of an Android ActivityIndicator changed the color of the rest of ActivityIndicators in the same page. * test: Updated ActivityIndicator sample. * perf: Call mutate() only if color is actually changed.
This commit is contained in:

committed by
GitHub

parent
d09a564296
commit
e16bc606ef
@ -1,4 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<Page>
|
<Page>
|
||||||
<ActivityIndicator busy="true" verticalAlignment="center" horizontalAlignment="center"/>
|
<StackLayout>
|
||||||
|
<ActivityIndicator busy="true" color="red" verticalAlignment="center" horizontalAlignment="center"/>
|
||||||
|
<ActivityIndicator busy="true" color="green" verticalAlignment="center" horizontalAlignment="center"/>
|
||||||
|
<ActivityIndicator busy="true" color="blue" verticalAlignment="center" horizontalAlignment="center"/>
|
||||||
|
<ActivityIndicator busy="true" color="" verticalAlignment="center" horizontalAlignment="center"/>
|
||||||
|
</StackLayout>
|
||||||
</Page>
|
</Page>
|
||||||
|
@ -47,10 +47,12 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
[colorProperty.setNative](value: number | Color) {
|
[colorProperty.setNative](value: number | Color) {
|
||||||
if (value instanceof Color) {
|
const color = value instanceof Color ? value.android : value;
|
||||||
this.nativeViewProtected.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
const drawable = this.nativeViewProtected.getIndeterminateDrawable().mutate();
|
||||||
|
if (color) {
|
||||||
|
drawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
} else {
|
} else {
|
||||||
this.nativeViewProtected.getIndeterminateDrawable().clearColorFilter();
|
drawable.clearColorFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user