You must redefine this method in your work. When a user changes the Display or TextSize screen, he changes the system configuration parameters, and then your application also selects these configuration parameters, and in the whole application the font size becomes larger or smaller. This may disrupt the appearance of your applications. If you want to set up the same configurations, you can implement the code below. You can change the font size by setting config.fontScale = your choice; You can check on fontScale on different screen sizes.
@Override protected void attachBaseContext(Context newBase) { Log.d(TAG, "attachBaseContext: "); super.attachBaseContext(newBase); Log.v(TAG, "attachBaseContext: Applying new configuration"); Resources res = newBase.getResources(); Configuration config = new Configuration(); config.fontScale = 1.0f; res.updateConfiguration(config, res.getDisplayMetrics()); }
source share