mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(android): background color is not applied to certain views (#10652)
This commit is contained in:

committed by
GitHub

parent
d6922b9896
commit
4f367483ef
@ -189,6 +189,10 @@ export class ActionBar extends ActionBarBase {
|
||||
this.update();
|
||||
}
|
||||
|
||||
override get needsNativeDrawableFill(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
public update() {
|
||||
if (!this.nativeViewProtected) {
|
||||
return;
|
||||
|
@ -106,6 +106,10 @@ export class Button extends ButtonBase {
|
||||
}
|
||||
}
|
||||
|
||||
override get needsNativeDrawableFill(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
[minWidthProperty.getDefault](): CoreTypes.LengthType {
|
||||
const dips = org.nativescript.widgets.ViewHelper.getMinWidth(this.nativeViewProtected);
|
||||
|
||||
|
@ -1134,7 +1134,8 @@ export class View extends ViewCommon {
|
||||
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();
|
||||
|
||||
AndroidHelper.setDrawableColor(backgroundColor, backgroundDrawable);
|
||||
|
4
packages/core/ui/core/view/index.d.ts
vendored
4
packages/core/ui/core/view/index.d.ts
vendored
@ -781,6 +781,10 @@ export abstract class View extends ViewCommon {
|
||||
* @private
|
||||
*/
|
||||
isLayoutRequired: boolean;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
get needsNativeDrawableFill(): boolean;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
@ -984,6 +984,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
return true;
|
||||
}
|
||||
|
||||
get needsNativeDrawableFill(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
Reference in New Issue
Block a user