Ranjithkumar
Ranjithkumar

Reputation: 18386

How to set dynamic font sizes for Xamarin portable project

I am very beginner for Xamarin Environment.

I have develop the portable project using Xamarin forms & it works fine in multi-platforms (Android,IOS,windows)

My problem:

In android it have multiple devices so they maintain different dimension folder structure for multi-device management.

For example:

My Xamarin Form code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local="clr-namespace:MultiDeviceDemo"
         x:Class="MultiDeviceDemo.MainPage">

<!--currently fontsize hardcoded.. How to replace this to dyanamic-->
<Label Text="Welcome to Xamarin Forms!"
       VerticalOptions="Center"
       HorizontalOptions="Center" 
     FontSize="30"/>

</ContentPage>

My question:

In my above

FontSize="30"

was hard-coded.. I want to replace this to value to android dimension structure.

How to set dynamic font sizes for label?

Upvotes: 1

Views: 2301

Answers (1)

Yehor Hromadskyi
Yehor Hromadskyi

Reputation: 3388

You could use platform idiom:

<Label>
  <Label.FontSize>
    <OnIdiom x:TypeArguments="x:Double"
             Phone="20"
             Tablet="40"/>
  </Label.FontSize>
</Label>

Upvotes: 5

Related Questions