Home > Back-end >  Xamarin forms get font size setting
Xamarin forms get font size setting

Time:07-01

Can I get this font size setting in my main Xamarin project. I like to set this RowHeight value for just the Android's.

xaml

<Grid.RowDefinitions>
    <RowDefinition Height="{Binding RowHeight}"></RowDefinition>
</Grid.RowDefinitions>

enter image description here

CodePudding user response:

So you can, you need to account for the platform variations by using the

Device.GetNamedSize 

method, which takes a NamedSize enum to designate the font size, and then the type which could be label, or other view that could be handled. So if you want to base this off of a label with medium size, run:

RowHeight = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) 
  (consider adding some padding to account for margin etc here);

https://docs.microsoft.com/en-us/dotnet/api/Xamarin.Forms.NamedSize?view=xamarin-forms

  • Related