diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts b/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts index b42a79aac..8cc4a216d 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts @@ -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 = 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]); + } } } diff --git a/tns-core-modules/ui/styling/background.android.ts b/tns-core-modules/ui/styling/background.android.ts index 2d47e0af8..7db04bfca 100644 --- a/tns-core-modules/ui/styling/background.android.ts +++ b/tns-core-modules/ui/styling/background.android.ts @@ -79,7 +79,12 @@ export module ad { backgroundDrawable = new org.nativescript.widgets.BorderDrawable(density, v.toString()); refreshBorderDrawable(v, backgroundDrawable); - nativeView.setBackground(backgroundDrawable); + + if (getSDK() >= 16) { + nativeView.setBackground(backgroundDrawable); + } else { + nativeView.setBackgroundDrawable(backgroundDrawable); + } } else { refreshBorderDrawable(v, 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)); + } } }