Disabling an app or activity zoom if Setting -> Display -> Display size changed to Large or small

android, android-manifest, android-settings

Solution

I have found a solution for it.

If system text size changed or Display size set to Large (Above Android Oreo), Your app will behave as normal (No big text and and zoomed views) with below code:

        Configuration configuration = getResources().getConfiguration();
        configuration.fontScale = (float) 1; //0.85 small size, 1 normal size, 1,15 big etc
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        metrics.scaledDensity = configuration.fontScale * metrics.density;
        configuration.densityDpi = (int) getResources().getDisplayMetrics().xdpi;
        getBaseContext().getResources().updateConfiguration(configuration, metrics);

Problem

In my app, I don't want to allow it to resize as its creating design issues. I have tried with `android:resizeableActivity="false"` in the application tag and the launcher activity tag but it didn't help.

Original source