Maui
Maui copied to clipboard
[BUG] Android button's text in Popup not aligned to center
Is there an existing issue for this?
- [X] I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
Button text is not centered when inside a popup in the reproduction repository here: https://github.com/czmirek/MauiButtonAlignBug
Expected Behavior
The button text is aligned to center correctly.
Steps To Reproduce
- https://github.com/czmirek/MauiButtonAlignBug
- Run in debug in Android Simulator --- Android 12.1, API 32
- Click on "Show popup"
- Observe button text not centered
Link to public reproduction project repository
https://github.com/czmirek/MauiButtonAlignBug
Environment
- .NET MAUI CommunityToolkit: 7.0.1
- .NET MAUI: 8.0.7
- OS: Android 12.1, API 32
- Happens in both Debug and Release
Anything else?
- Go to TestPopup.xaml and remove the style from the
<Button>
- It is centered now
But as you can see in App.xaml
there is nothing in the styles that should affect how the text inside the button is aligned.
<ResourceDictionary>
<Color x:Key="PrimaryColor">#FFBB00</Color>
<Color x:Key="TextColor">#000000</Color>
<Style TargetType="Button" x:Key="BaseButton">
<Setter Property="CornerRadius" Value="{OnPlatform 25}" />
<Setter Property="Padding" Value="20,10,20,10" />
<Setter Property="FontSize" Value="16" />
<Setter Property="HeightRequest" Value="48" />
</Style>
<Style TargetType="Button" x:Key="PrimaryButton" BasedOn="{StaticResource BaseButton}">
<Setter Property="BackgroundColor" Value="{StaticResource PrimaryColor}" />
<Setter Property="TextColor" Value="{StaticResource TextColor}" />
</Style>
</ResourceDictionary>