mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Use setBackgroundDrawable for API < 16. (#3108)
This commit is contained in:
committed by
Vladimir Enchev
parent
c669fa8281
commit
978bd8c524
@@ -290,7 +290,11 @@ export class SegmentedBarStyler implements style.Styler {
|
||||
stateDrawable.addState(arr, colorDrawable);
|
||||
stateDrawable.setBounds(0, 15, vg.getRight(), vg.getBottom());
|
||||
|
||||
vg.setBackground(stateDrawable);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 16) {
|
||||
vg.setBackground(stateDrawable);
|
||||
} else {
|
||||
vg.setBackgroundDrawable(stateDrawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +303,12 @@ export class SegmentedBarStyler implements style.Styler {
|
||||
ensureSegmentedBarColorDrawableClass();
|
||||
for (let tabIndex = 0; tabIndex < tabHost.getTabWidget().getTabCount(); tabIndex++) {
|
||||
let vg = <android.view.ViewGroup>tabHost.getTabWidget().getChildTabViewAt(tabIndex);
|
||||
vg.setBackground(nativeValue[tabIndex]);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 16) {
|
||||
vg.setBackground(nativeValue[tabIndex]);
|
||||
} else {
|
||||
vg.setBackgroundDrawable(nativeValue[tabIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,12 @@ export module ad {
|
||||
|
||||
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(density, v.toString());
|
||||
refreshBorderDrawable(v, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
||||
nativeView.setBackground(backgroundDrawable);
|
||||
|
||||
if (getSDK() >= 16) {
|
||||
nativeView.setBackground(backgroundDrawable);
|
||||
} else {
|
||||
nativeView.setBackgroundDrawable(backgroundDrawable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
refreshBorderDrawable(v, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
||||
@@ -96,12 +101,21 @@ export module ad {
|
||||
// reset the value with the default native value
|
||||
if (v instanceof button.Button) {
|
||||
let nativeButton = new android.widget.Button(nativeView.getContext());
|
||||
nativeView.setBackground(nativeButton.getBackground());
|
||||
|
||||
if (getSDK() >= 16) {
|
||||
nativeView.setBackground(nativeButton.getBackground());
|
||||
} else {
|
||||
nativeView.setBackgroundDrawable(nativeButton.getBackground());
|
||||
}
|
||||
}
|
||||
else {
|
||||
let viewClass = types.getClass(v);
|
||||
if (_defaultBackgrounds.has(viewClass)) {
|
||||
nativeView.setBackground(_defaultBackgrounds.get(viewClass));
|
||||
if (getSDK() >= 16) {
|
||||
nativeView.setBackground(_defaultBackgrounds.get(viewClass));
|
||||
} else {
|
||||
nativeView.setBackgroundDrawable(_defaultBackgrounds.get(viewClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user