Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions packages/core/ui/core/view/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,8 @@ export class View extends ViewCommon {
ViewHelper.setOutlineProvider(nativeView, background.borderTopLeftRadius, background.borderTopRightRadius, background.borderBottomRightRadius, background.borderBottomLeftRadius);
}
if (nativeView._borderForeground) {
nativeView.setForeground(null);
nativeView._borderForeground = null;
this._updateForeground();
}
} else {
// the view clips its children to its rounded corners (outline). The border is then drawn by the foreground, over the children:
Expand All @@ -1345,10 +1345,10 @@ export class View extends ViewCommon {
nativeView._borderForeground = new org.nativescript.widgets.BorderDrawable(layout.getDisplayDensity(), this.toString());
}
refreshBorderDrawable(this, nativeView._borderForeground, 'border');
nativeView.setForeground(nativeView._borderForeground);
this._updateForeground();
} else if (nativeView._borderForeground) {
nativeView.setForeground(null);
nativeView._borderForeground = null;
this._updateForeground();
}
if (background.clearFlags & BackgroundClearFlags.CLEAR_BACKGROUND_COLOR) {
if (backgroundDrawable) {
Expand Down Expand Up @@ -1397,6 +1397,27 @@ export class View extends ViewCommon {
}
org.nativescript.widgets.Utils.drawBoxShadow(nativeView, nativeArray);
}
/**
* The native view has a single foreground, shared by the border drawn over the children (`_borderForeground`) and a ripple
* (`_rippleForeground`, set by the ui-core plugin). Both are kept: the border is drawn over the ripple.
*/
_updateForeground(): void {
const nativeView = this.nativeViewProtected;
if (!nativeView) {
return;
}
const ripple = nativeView._rippleForeground;
const border = nativeView._borderForeground;
if (ripple && border) {
const layers = Array.create(android.graphics.drawable.Drawable, 2);
layers[0] = ripple;
layers[1] = border;
nativeView.setForeground(new android.graphics.drawable.LayerDrawable(layers));
} else {
nativeView.setForeground(ripple || border || null);
}
}

_redrawNativeBackground(value: android.graphics.drawable.Drawable | Background): void {
if (value instanceof Background) {
this.onBackgroundOrBorderPropertyChanged();
Expand Down
1 change: 1 addition & 0 deletions packages/core/ui/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface NativeScriptAndroidView extends android.view.View {
_cachedDrawable: android.graphics.drawable.Drawable;
_borderForeground?: org.nativescript.widgets.BorderDrawable;
_rippleForeground?: android.graphics.drawable.Drawable;
}

export interface NativeScriptUIView extends UIView {
Expand Down
Loading