This question is a almost dublicate of Android App: how to read Font Size under Settings? I read the answer of CommonsWare which points to use Settings.System.FONT_SCA
I just found in the source code of Settings.System this function:
/** @hide */
public static void getConfigurationForUser(ContentResolver cr,
Configuration outConfig, int userHandle) {
outConfig.fontScale = Settings.System.getFloatForUser(
cr, FONT_SCALE, outConfig.fontScale, userHandle);
if (outConfig.fontScale < 0) {
outConfig.fontScale = 1;
}
}
There is however the FONT_SCALE in usage so I checked for that Configuration class where the documentation points to getResources().getConfiguration(). So I cound fix my code by using:
float scale = getResources().getConfiguration().fontScale;