Search code examples
androidandroid-layoutfontsscreentruetype

Android Application Layout Broken by LARGE text


I have an Android Application that caters for all four screens sizes, e.g. SMALL, NORMAL, LARGE, and EXTRA LARGE. For each size I have portrait and landscape layouts.

I have some negative feedback from my users saying that on certain screens the layout does not "fit", e.g. the layout has exceeded the physical screen size.

I have identified two possible causes

  1. The user has switched to a "Non standard" font which has caused my application literals to split over multiple lines

  2. The user has selected LARGE font size in the phone settings that has the same effect as 1). above

is there a technique i can use that keeps my application immune from these type of user configuration changes?

My application has its own TTF fonts which I load from the local assets folder. I thought this would keep my application isolated from the above mentioned problems.


Solution

  • The system font overrides anything you do in your app, so I think you're out of luck. Think about it this way: the users who tend to set their system font size to large typically have some sort of vision impairment that demands larger, more easily readable text. So if your app forces a smaller font on them to preserve your sense of aesthetics, those users aren't going to be very happy. The concept of "user experience" suggests that the code serves the user, and not the other way around.

    If you really insist on mandating strict font sizes, then you can simply make images of your text and use ImageView in favor of TextView. This way, no matter what the user does to his font or font size, the text is actually an image, and will therefore be unaffected. I provide this suggestion strictly in the spirit of answering your question exactly, but I would strongly caution you against going to such draconian lengths. Localization will become a nightmare, and you may end up losing users who want control over fonts and font sizes for whatever reason.