mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 13:51:27 +08:00
Merge pull request #1064 from NativeScript/feature/rounded-corners-android-17
Use software layer for rounded borders on android 17
This commit is contained in:
@ -13,6 +13,8 @@ var btn;
|
|||||||
|
|
||||||
global.moduleMerge(stylersCommon, exports);
|
global.moduleMerge(stylersCommon, exports);
|
||||||
|
|
||||||
|
var SDK = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
var ignorePropertyHandler = new stylersCommon.StylePropertyChangedHandler(
|
var ignorePropertyHandler = new stylersCommon.StylePropertyChangedHandler(
|
||||||
(view, val) => {
|
(view, val) => {
|
||||||
// empty
|
// empty
|
||||||
@ -51,6 +53,12 @@ function onBackgroundOrBorderPropertyChanged(v: view.View) {
|
|||||||
bkg.cornerRadius = v.borderRadius;
|
bkg.cornerRadius = v.borderRadius;
|
||||||
bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
|
bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
|
||||||
bkg.background = backgroundValue;
|
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 {
|
else {
|
||||||
// reset the value with the default native value
|
// reset the value with the default native value
|
||||||
@ -64,6 +72,11 @@ function onBackgroundOrBorderPropertyChanged(v: view.View) {
|
|||||||
nativeView.setBackground(_defaultBackgrounds.get(viewClass));
|
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();
|
var density = utils.layout.getDisplayDensity();
|
||||||
|
Reference in New Issue
Block a user