While developing my app I realised if someone changes device font size from normal, my application font sizes change too and it destroys some of the visuals I designed. So I wan
check the source code DisplaySettings.java, here is the method to control font size scale
public void writeFontSizePreference(Object objValue) {
try {
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
} catch (RemoteException e) {
Log.w(TAG, "Unable to save font size");
}
}
here is a solution keep the font size in different fontscale.
float textSize = 22f;
mTextView.setTextSize(textSize / getResources().getConfiguration().fontScale);
and I think @shoe rat's answer is more better for an activity or application context.