Maui android button text not centered

Haviv Elbsz 2,071 Reputation points
2022-12-08T21:05:14.207+00:00

Hi all

The text in my maui app not show exactly at
the centre of the button.

is horizontaloption = centre not works ?

the button corners are rounded is this
concerning.

Thank you very much

Developer technologies .NET .NET MAUI
Developer technologies C#
{count} votes

Accepted answer
  1. Anonymous
    2022-12-09T07:12:14.557+00:00

    Hello,

    Try to add the blew padding and set width request in the button like following code.

       <Button  
                       x:Name="CounterBtn"  
                       HeightRequest="40"  
                       WidthRequest="70"  
                       CornerRadius="20"  
                       Padding="0,0,0,2"  
                       BorderColor="Black"  
                       Text="size +"  
                       HorizontalOptions="Center"  
                       />  
    

    ===========
    Update ===========

    Or you can open the style.xaml(Resources folder=> Styles.xaml) to find the <Style TargetType="Button"> tag and remove <Setter Property="Padding" Value="14,10"/> line.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.