2

How do we change font type and font size programmatically? I am not referring to changing the font style of a textview or editText.

I want to change the global font settings, toggling between font types and font sizes on a button click in my app. I tried checking the Settings.System attributes but I could not find them. Any ideas?

Somanadh
  • 97
  • 2
  • 11
SoulRayder
  • 5,072
  • 6
  • 47
  • 93

3 Answers3

4

You can change system font using below code

Settings.System.putFloat(getBaseContext().getContentResolver(),
            Settings.System.FONT_SCALE, (float) 1.0);

and after this give permission in menifest file

  <uses-permission android:name="android.permission.WRITE_SETTINGS"/>

and then restart your device to show effect..

Note: Its fully applicable for rooted device and in Unrooted device some font may change and some are not.

0

You can use FONT_SCALE from android.provider.Settings.System.

and also see this.

Read font size from Settings

Hope this might help you.

Community
  • 1
  • 1
Shadow
  • 6,864
  • 6
  • 44
  • 93
0

Use the method above, in addition to allowing the app to ask the user for permissions.

Instructions are available here : Can't get WRITE_SETTINGS permission

nyxee
  • 2,773
  • 26
  • 22