What is the font size unit in xamarin forms

I do not have clarity on font size unit in Xamarin forms.
What unit is used by Xamarin Forms on Android and iOS?
I want to set scaled font size in numeric not string that is provided by Xamarin Forms like Large, Medium etc.
Please suggest.

Best Answer


  • PrashantWaliaPrashantWalia USMember ✭✭
    Can i use sp(scaled pixel) for android. And for iOS font size is in Point right?
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited August 2018

    Just do it like the rest of the industry. You're working in Xamarin.Forms now. Everything is device independent.
    Let Xamarin do its job. 44 in one device will match 44 on another.

  • PrashantWaliaPrashantWalia USMember ✭✭
    Actually i do not have clarity on this if you can explain it would be very helpful.
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Clarity on what? What part of that is unclear?

    You do all your work at the shared layer which is device and platform agnostic. Your code and your your UI XAML markup doesn't know what it is running on. It could be a Samsung Android Tablet. It could be an Apple iPhone. Your UI doesn't know or care.
    Xamarin handles the adjustments for devices.
    If you want a Label presented at 28 it will look the same on Android and iPhone. The Xamarin system will adjust for you - you don't have to micro manage that.

  • PrashantWaliaPrashantWalia USMember ✭✭
    UX desginer has desgined screen for 1080*1920(xxhdpi) and they are saying me to use 14pixel font size so should i give 14 in xaml or something else?
    And same question is for height they want 142pixel on xxhdpi scrren so what numeric value should i use?
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Your UX designer doesn't understand the intricate details of mobile development then.
    For one, the user might have magnification set higher than normal at the OS level. Suddenly the fonts won't be the size you think they are.

    Also... Nobody does UI design with such hard-set rules like 142px these days. There's just too many different devices out there. 1080x1920 is only a very small subset of devices. Plus the available real estate can change as soon as a new version of the OS comes out. For example, as soon as Android OS blahblah comes out, maybe the title bar changes from 32px tall to 35px tall. Suddenly your available free screen space drops by 3 pixel rows.
    Come to think of it... 1920x1080 doesn't account for the title bar put on the OS. So already I see a problem.

    For now... Yeah, just make the fonts 14 or whatever he says. Let your bosses realize down the line that this guy doesn't understand UX for mobile devices. That's their problem for not hiring well: Its not your fault.

  • PrashantWaliaPrashantWalia USMember ✭✭
    Thanks for your quick responses and I know its going a long discussion but actually i want a solution for this. What i have found out for now is whatever size they will tell me in px i just devide that by 3 and use that numeric value.
    Lets say that want 142 so i am using 142/3= 47.3 in xaml. I devide by 3 because base screen size in xaml is mdpi and us designer uded xxhdpi that is @3x of mdpi.

    But for font size i do not know the unit and as you said it is DIP but if i do so like they say for 14px font size and i use 14/3=4.3 then it is very small as compared to screen that they desgin.
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    There's no "divide by 3" for it. If they say 14 use 14.

    because base screen size in xaml is mdpi

    No idea where you go that idea from. But, no.

Sign In or Register to comment.