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?
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.
You can use FONT_SCALE
from android.provider.Settings.System
.
and also see this.
Hope this might help you.
来源:https://stackoverflow.com/questions/23421676/how-to-programmatically-change-font-settings-of-device-font-style-and-font-size