From 67f992fc57fe51a395c36d8d259803cb6168b33d Mon Sep 17 00:00:00 2001 From: vakrilov Date: Mon, 9 Nov 2015 16:29:21 +0200 Subject: [PATCH] Use software layer for rounded borders on android 17 --- ui/styling/stylers.android.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui/styling/stylers.android.ts b/ui/styling/stylers.android.ts index 94c5881ee..56f7c461b 100644 --- a/ui/styling/stylers.android.ts +++ b/ui/styling/stylers.android.ts @@ -13,6 +13,8 @@ var btn; global.moduleMerge(stylersCommon, exports); +var SDK = android.os.Build.VERSION.SDK_INT; + var ignorePropertyHandler = new stylersCommon.StylePropertyChangedHandler( (view, val) => { // empty @@ -51,6 +53,12 @@ function onBackgroundOrBorderPropertyChanged(v: view.View) { bkg.cornerRadius = v.borderRadius; bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT; bkg.background = backgroundValue; + + if (SDK < 18) { + // Switch to software because of unsupported canvas methods if hardware acceleration is on: + // http://developer.android.com/guide/topics/graphics/hardware-accel.html + nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null); + } } else { // reset the value with the default native value @@ -64,6 +72,11 @@ function onBackgroundOrBorderPropertyChanged(v: view.View) { nativeView.setBackground(_defaultBackgrounds.get(viewClass)); } } + + if (SDK < 18) { + // Reset layer type to hardware + nativeView.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null); + } } var density = utils.layout.getDisplayDensity();