mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +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();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override get needsNativeDrawableFill(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public update() {
|
public update() {
|
||||||
if (!this.nativeViewProtected) {
|
if (!this.nativeViewProtected) {
|
||||||
return;
|
return;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
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
|
* @private
|
||||||
*/
|
*/
|
||||||
isLayoutRequired: boolean;
|
isLayoutRequired: boolean;
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
get needsNativeDrawableFill(): boolean;
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user