I have website using Webview I created Android application. I want the text size same as website in android application. And text size should not change if user increase or decrease text size from mobile setting.
CodePudding user response:
This will force the App to use the Phone's 'default' text size. Even if the user goes into Phone Settings and changes the font size, it will stay default in the App..
Configuration configuration = getResources().getConfiguration();
configuration.fontScale = 1.0f;
DisplayMetrics metrics = getResources().getDisplayMetrics();
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metrics);
metrics.scaledDensity = configuration.fontScale * metrics.density;
getResources().updateConfiguration(configuration, metrics);
CodePudding user response:
Try to use dp instead of sp. If you already use dp, give us the xml code of an Activity with TextView to find out where the problem is.