Jefferson
Jefferson

Reputation: 93

Xamarin forms get font size setting

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

Upvotes: 0

Views: 372

Answers (1)

Christopher Richmond
Christopher Richmond

Reputation: 656

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://learn.microsoft.com/en-us/dotnet/api/Xamarin.Forms.NamedSize?view=xamarin-forms

Upvotes: 1

Related Questions