8000 fix(android): background color is not applied to certain views (#10652) · NativeScript/NativeScript@4f36748 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f36748

Browse files
authored
fix(android): background color is not applied to certain views (#10652)
1 parent d6922b9 commit 4f36748

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

packages/core/ui/action-bar/index.android.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ export class ActionBar extends ActionBarBase {
189189
this.update();
190190
}
191191

192+
override get needsNativeDrawableFill(): boolean {
193+
return true;
194+
}
195+
192196
public update() {
193197
if (!this.nativeViewProtected) {
194198
return;

packages/core/ui/button/index.android.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ export class Button extends ButtonBase {
106106
}
107107
}
108108

109+
override get needsNativeDrawableFill(): boolean {
110+
return true;
111+
}
112+
109113
[minWidthProperty.getDefault](): CoreTypes.LengthType {
110114
const dips = org.nativescript.widgets.ViewHelper.getMinWidth(this.nativeViewProtected);
111115

packages/core/ui/core/view/index.android.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,8 @@ export class View extends ViewCommon {
11341134
nativeView.setBackground(backgroundDrawable);
11351135
}
11361136

1137-
if (backgroundDrawable) {
1137+
// Apply color to drawables when there is the need to maintain visual things like button ripple effect
1138+
if (this.needsNativeDrawableFill && backgroundDrawable) {
11381139
backgroundDrawable.mutate();
11391140

11401141
AndroidHelper.setDrawableColor(backgroundColor, backgroundDrawable);

packages/core/ui/core/view/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ export abstract class View extends ViewCommon {
781781
* @private
782782
*/
783783
isLayoutRequired: boolean;
784+
/**
785+
* @private
786+
*/
787+
get needsNativeDrawableFill(): boolean;
784788
/**
785789
* @private
786790
*/

packages/core/ui/core/view/view-common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
984984
return true;
985985
}
986986

987+
get needsNativeDrawableFill(): boolean {
988+
return false;
989+
}
990+
987991
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
988992
this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec);
989993
}

0 commit comments

Comments
 (0)
0