Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android applications font size changes according to the defined font size in settings

I have developed an android application to work with small, medium and large screen sized devices.

But recently I came across the following issue.

When I go to the settings and change the font size to Extra Large instead of default Medium size [Settings --> Display --> Font size], my apps font size also gets increase accordingly and the layouts get mess up.

Have anyone previously experienced this and would be grateful for any Idea for a solution which will not continue this messed up situation.

Edits...

I have used the "sp" units to define all the font sizes within the application...

like image 945
JibW Avatar asked Dec 26 '22 10:12

JibW


2 Answers

Have anyone previously experienced this

This is what sp gives you: automatic-scaling fonts based upon the user's chosen font scale.

and would be grateful for any Idea for a solution which will not continue this messed up situation.

Ideally, you would fix your GUI implementation, so that you can accommodate changes in font scale. If the user has requested larger fonts, your app should support this. This is no different than designing a Web app that takes into account browser font size changes.

In a pinch, stop using sp units, but then do not complain if your users complain that you do not honor their requested font scale.

For more, see this blog post of mine.

like image 148
CommonsWare Avatar answered Jan 18 '23 23:01

CommonsWare


I had the problem myself in a widget. There is no room to let the user have any thing to say about the font size. The solution is pretty simple:

  • Use dp instead of sp.

Then you get the correct scaling according to have the dpi on different screens but it wont change depending on the users selected font size.

like image 31
Flaxie Avatar answered Jan 18 '23 22:01

Flaxie