Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When creating a Button with text in Xamarin Forms and increasing the font size in the mobile settings, the text does not fit on the Button. Is there a way to adjust the size of the text to the Button?

Button code:

<Button
                        BackgroundColor="{StaticResource color1gray}"
                        BorderRadius="5"
                        HeightRequest="30"
                        Text="Cancelar"
                        WidthRequest="150" />
question from:https://stackoverflow.com/questions/65903048/how-to-align-button-text-when-increasing-font-size-in-settings

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

It seems that height adjustment cannot be made automatically because you set " HeightRequest=50". You can easily resolve the problem with deleting HeightRequest=50 from your button.

enter image description here

It is better to use Grid to adjust the height according to the screensize. Example:

<Grid>
   <Grid.RowDefinitions>
      <RowDefinition Height="80*" />
      <RowDefinition Height="20*" />
   </Grid.RowDefinitions>
   <Grid Grid.Row="0">
   </Grid>

   <Button Grid.Row="1" BackgroundColor="{StaticResource color1gray}"
                        BorderRadius="5"
                        VerticalOptions="Center"
                        HorizontalOptions="Center"
                        Text="Cancelar" />
</Grid>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...