[FIXED] Xamarin forms get font size setting

Issue

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

Solution

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

Answered By – Christopher Richmond

Answer Checked By – Dawn Plyler (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published