mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
setColorFilter used if android.os.Build.VERSION.SDK_INT >= 21 (#3143)
This commit is contained in:
@ -129,7 +129,7 @@ export class SegmentedBar extends common.SegmentedBar {
|
|||||||
var that = new WeakRef(this);
|
var that = new WeakRef(this);
|
||||||
|
|
||||||
this._listener = new android.widget.TabHost.OnTabChangeListener({
|
this._listener = new android.widget.TabHost.OnTabChangeListener({
|
||||||
onTabChanged: function(id: string) {
|
onTabChanged: function (id: string) {
|
||||||
var bar = that.get();
|
var bar = that.get();
|
||||||
if (bar) {
|
if (bar) {
|
||||||
bar.selectedIndex = parseInt(id);
|
bar.selectedIndex = parseInt(id);
|
||||||
@ -282,6 +282,10 @@ export class SegmentedBarStyler implements style.Styler {
|
|||||||
for (let tabIndex = 0; tabIndex < tabHost.getTabWidget().getTabCount(); tabIndex++) {
|
for (let tabIndex = 0; tabIndex < tabHost.getTabWidget().getTabCount(); tabIndex++) {
|
||||||
let vg = <android.view.ViewGroup>tabHost.getTabWidget().getChildTabViewAt(tabIndex);
|
let vg = <android.view.ViewGroup>tabHost.getTabWidget().getChildTabViewAt(tabIndex);
|
||||||
|
|
||||||
|
var backgroundDrawable = vg.getBackground();
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 21 && backgroundDrawable && types.isFunction(backgroundDrawable.setColorFilter)) {
|
||||||
|
backgroundDrawable.setColorFilter(newValue, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
} else {
|
||||||
let stateDrawable = new android.graphics.drawable.StateListDrawable();
|
let stateDrawable = new android.graphics.drawable.StateListDrawable();
|
||||||
|
|
||||||
let arr = (<any>Array).create("int", 1);
|
let arr = (<any>Array).create("int", 1);
|
||||||
@ -297,6 +301,7 @@ export class SegmentedBarStyler implements style.Styler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static resetSelectedBackgroundColorProperty(v: view.View, nativeValue: Array<android.graphics.drawable.Drawable>) {
|
private static resetSelectedBackgroundColorProperty(v: view.View, nativeValue: Array<android.graphics.drawable.Drawable>) {
|
||||||
let tabHost = <android.widget.TabHost>v._nativeView;
|
let tabHost = <android.widget.TabHost>v._nativeView;
|
||||||
|
Reference in New Issue
Block a user