Skip to content

.NET MAUI style problem with gradient colors - Android #11601

@AbanoubZak

Description

@AbanoubZak

Description

I started using .NET MAUI recently and I found a problem with Styling.
I started with the basic project to make sure the problem is not something I made during the process.
The project starts with a button that will change text and size each time the user press it.
enter image description here

The problem is any time I use LinearGradientBrush directly or through the global styling, the button size doesn't change to fit the text, and even worse it moves to the left.
enter image description here

I looked everywhere but I didn't find any similar problem or solution.

It works well with Windows but not with Android

Code

<Button
                x:Name="CounterBtn"
                Text="Click me"
                SemanticProperties.Hint="Counts the number of times you click"
                Clicked="OnCounterClicked"
                HorizontalOptions="Center">
                <Button.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#8A26ED"/>
                        <GradientStop Color="#381061" Offset="1"/>
                    </LinearGradientBrush>
                </Button.Background>
            </Button>

Steps to Reproduce

  1. Create new .NET MAUI app
  2. Set LinearGradientBrush to the CounterBtn button directly or use global styling.
  3. When the button click on Android the size doesn't change and the button moves to the left

Link to public reproduction project repository

https://github.com/AbanoubZak/NET-MAUI-gradient-color-styling-problem

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

All Android

Did you find any workaround?

Not yet

Relevant log output

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions