1

I found that some people might change their device fonts to large, that might ruined the app layout. is there anyway i can override the device setting to normal font size ?

Is there any api call so i can set the device font size back to normal and set it back to large when my app close or pause programmatically ?

user3491799
  • 322
  • 4
  • 16
  • You can force font scale to 1.0 or any other factor https://stackoverflow.com/questions/21546805/how-to-prevent-system-font-size-changing-effects-to-android-application/53970324#53970324 – Maxim Saplin Dec 29 '18 at 14:19

2 Answers2

0

Use the unit dp or px when defining the font size (as opposed to sp). Using either of the first to will set the font size to a static size, while sp will cause the font size to dynamically change with the user's font size preference.

MisterEman22
  • 238
  • 2
  • 10
  • i use sp already, but when user change the font size from normal to large / huge in the device settings, the font with sp setting will increase as well. that will ruined the layout. is there anyway to override or set device font size to normal only for this app – user3491799 Aug 08 '15 at 03:06
  • is there an api call set the device back to normal font size, and when the app quit or pause i set it back to large in programatically ? because normal size fonts works on pad version too, if i use dp / px , the fonts will be tiny in pad – user3491799 Aug 08 '15 at 03:09
  • There is no need to change the device font size if you use dp to set the size of the font. That will cause it to be the same no matter what the device's font size is set to. – MisterEman22 Aug 08 '15 at 03:13
  • yes the font size will be fixed, but the fonts will be too tiny on a 10" pad – user3491799 Aug 08 '15 at 03:17
  • you can create a different dimen for 10" pads. – Angel Koh Aug 08 '15 at 03:51
0

Be as device-independent as possible. Whatever the device's font setting, your app's font sizes should scale smoothly with it as long as you don't set them to pixels.

Always favour scale-independent pixels(sp) over pixels (px) for your units when setting font sizes, e.g. 12sp instead of 12px.

EDIT: You may need to adjust the layouts for large screens to better match the behaviour you are now seeing so as to avoid being invasive to your users by forcing them back to the setting they changed from. Use appropriate layout qualifiers for proper size selection at run-time.

Refer to this: Supporting Multiple Screens on the android developer site.

Dut A.
  • 1,029
  • 11
  • 22
  • but when user change the font size from normal to large / huge in the device settings, the font with sp setting will increase as well. – user3491799 Aug 08 '15 at 03:16
  • please check the note in my "Edit", it may help. – Dut A. Aug 08 '15 at 03:23
  • i am talking about same device with the same screen size (eg. 4.7" LCD). if user change the font size from normal to large, it will affect the layout. – user3491799 Aug 08 '15 at 03:28
  • It would be helpful to give a sample layout setup you have so I can give it a try on my phone. – Dut A. Aug 08 '15 at 03:30