I want my layout to be of the same size and shape throughout and previously adjusting the font scale was working fine. Now android seems to have come up with the option of changing display size which is disorienting my whole layout.
I have tried making a values-large, layout-large and tried setting normal sizes to the layout but to no positive result.
I also found this code in some thread to help me with my problem:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Log.d("TAG", "adjustDisplayScale: " + configuration.densityDpi);
DisplayMetrics metrics = getResources().getDisplayMetrics();
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(metrics);
if (configuration.densityDpi >= 485) //for 6 inch device OR for 538 ppi
configuration.densityDpi = 500; //decrease "display size" by ~30
else if (configuration.densityDpi >= 300) //for 5.5 inch device OR for 432 ppi
configuration.densityDpi = 400; //decrease "display size" by ~30
else if (configuration.densityDpi >= 100) //for 4 inch device OR for 233 ppi
configuration.densityDpi = 200; //decrease "display size" by ~30
Log.d("TAG", "metrics density: " + metrics.density + "," + metrics.scaledDensity);
metrics.scaledDensity = configuration.densityDpi * metrics.density;
Log.d("TAG", "scaledDensity: " + metrics.scaledDensity);
this.getResources().updateConfiguration(configuration, metrics);
}
This also doesn't seem to do any good to my layout. It still becomes huge and disoriented. Can anybody tell me what I can do to maintain the same size throughout without the system settings affecting my layouts and design?