fix(android): background color is not applied to certain views (#10652)

This commit is contained in:
Dimitris-Rafail Katsampas
2024-11-19 05:45:30 +02:00
committed by GitHub
parent d6922b9896
commit 4f367483ef
5 changed files with 18 additions and 1 deletions

View File

@ -189,6 +189,10 @@ export class ActionBar extends ActionBarBase {
this.update(); this.update();
} }
override get needsNativeDrawableFill(): boolean {
return true;
}
public update() { public update() {
if (!this.nativeViewProtected) { if (!this.nativeViewProtected) {
return; return;

View File

@ -106,6 +106,10 @@ export class Button extends ButtonBase {
} }
} }
override get needsNativeDrawableFill(): boolean {
return true;
}
[minWidthProperty.getDefault](): CoreTypes.LengthType { [minWidthProperty.getDefault](): CoreTypes.LengthType {
const dips = org.nativescript.widgets.ViewHelper.getMinWidth(this.nativeViewProtected); const dips = org.nativescript.widgets.ViewHelper.getMinWidth(this.nativeViewProtected);

View File

@ -1134,7 +1134,8 @@ export class View extends ViewCommon {
nativeView.setBackground(backgroundDrawable); nativeView.setBackground(backgroundDrawable);
} }
if (backgroundDrawable) { // Apply color to drawables when there is the need to maintain visual things like button ripple effect
if (this.needsNativeDrawableFill && backgroundDrawable) {
backgroundDrawable.mutate(); backgroundDrawable.mutate();
AndroidHelper.setDrawableColor(backgroundColor, backgroundDrawable); AndroidHelper.setDrawableColor(backgroundColor, backgroundDrawable);

View File

@ -781,6 +781,10 @@ export abstract class View extends ViewCommon {
* @private * @private
*/ */
isLayoutRequired: boolean; isLayoutRequired: boolean;
/**
* @private
*/
get needsNativeDrawableFill(): boolean;
/** /**
* @private * @private
*/ */

View File

@ -984,6 +984,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
return true; return true;
} }
get needsNativeDrawableFill(): boolean {
return false;
}
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void { public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec); this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec);
} }