Dan
Dan

Reputation: 1

MAUI Entry Control Font Size issue on Android

Newbie to MAUI cross-platform programming. Pretty much using the controls out of the box on VS2022 version 17.9.0 and IOS 17.x and Android API 33/34.
Between the IOS and Android emulators, the font looks normal in an entry control on IOS but gets really tiny on Android. Labels work fine. I tried setting FontSize, but that only worked in IOS. My markup is really basic at this point.

I'm sure the answer is something really basic, but I can't seem to find it.

shows the difference the same code looks like on android/iphone

No special configurations, nuget packages, or settings.

Upvotes: 0

Views: 565

Answers (2)

Dan
Dan

Reputation: 1

Andre Kraemer's comment was the clue I needed. I was using a grid container and that was causing the font issue. When I put similar markup in a FlexLayout, it rendered properly on an android emulator (and android device).

Upvotes: 0

Leon Lu
Leon Lu

Reputation: 9234

The OnPlatform class can be used in XAML to set font properties per platform. The example below sets different font sizes on different platforms:

<Entry
    FontSize="{OnPlatform iOS=30, Android=40, WinUI=20}"
    Text="this is maui project"/>

For more details about font setting, you can refer to Fonts in .NET MAUI

Upvotes: 0

Related Questions