4

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...

JibW
  • 4,538
  • 17
  • 66
  • 101

2 Answers2

6

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Hi CommonsWare, Thanks for the quick response. Yes as a practice I normally define the font sizes in "sp" units and all the other layout sizes in "dp" units. So here in this app also I have done the same thing. Still have this issue... – JibW Jan 29 '13 at 16:07
  • @JibW: Then you need to do a better job with your GUI design, such that when the fonts get scaled up, your layouts do not "get mess up". *You* wrote the layouts. *You* need to fix the layouts to accommodate the `sp`-based size changes. – CommonsWare Jan 29 '13 at 16:17
  • The thing is, the text size in all the EditTexts(Text boxes) also increases and it looks prety ugly. Was checking if there is a way to stop allowing this scaling thing within my application scope...Thanks – JibW Jan 29 '13 at 16:28
  • @JibW: As I wrote, "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". – CommonsWare Jan 29 '13 at 16:45
4

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.

Flaxie
  • 540
  • 3
  • 13