From e507d6403a4d42f3dca2fef592cfc0639160bb38 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Thu, 3 Nov 2016 16:49:12 +0200 Subject: [PATCH] Fix: Enhancement: Android Actionbar elevation lost with background-color Resolves #1799 --- tns-core-modules/ui/styling/background.android.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tns-core-modules/ui/styling/background.android.ts b/tns-core-modules/ui/styling/background.android.ts index 901d0986d..83e9344db 100644 --- a/tns-core-modules/ui/styling/background.android.ts +++ b/tns-core-modules/ui/styling/background.android.ts @@ -36,6 +36,13 @@ export module ad { let _defaultBackgrounds = new Map(); + function isSetColorFilterOnlyWidget(nativeView: android.view.View): boolean { + return ( + nativeView instanceof android.widget.Button || + nativeView instanceof android.support.v7.widget.Toolbar + ); + } + export function onBackgroundOrBorderPropertyChanged(v: view.View) { let nativeView = v._nativeView; if (!nativeView) { @@ -48,7 +55,8 @@ export module ad { let backgroundDrawable = nativeView.getBackground(); let density = utils.layout.getDisplayDensity(); let cache = v._nativeView; - if (v instanceof button.Button + + if (isSetColorFilterOnlyWidget(nativeView) && !types.isNullOrUndefined(backgroundDrawable) && types.isFunction(backgroundDrawable.setColorFilter) && !background.hasBorderWidth() @@ -63,7 +71,7 @@ export module ad { else if (!background.isEmpty()) { if (!(backgroundDrawable instanceof org.nativescript.widgets.BorderDrawable)) { let viewClass = types.getClass(v); - if (!(v instanceof button.Button) && !_defaultBackgrounds.has(viewClass)) { + if (!isSetColorFilterOnlyWidget(nativeView) && !_defaultBackgrounds.has(viewClass)) { _defaultBackgrounds.set(viewClass, nativeView.getBackground()); }