如果设置-&gt ;,则禁用应用或活动缩放。显示->显示尺寸更改为大或小 [英] Disabling an app or activity zoom if Setting -> Display -> Display size changed to Large or small

查看:114
本文介绍了如果设置-&gt ;,则禁用应用或活动缩放。显示->显示尺寸更改为大或小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我不希望由于其导致的设计问题而调整其大小。

In my app, I don't want to allow it to resize as its creating design issues.

我尝试使用 android: resizeableActivity = false 在应用程序标签和启动器活动标签中,但没有帮助。

I have tried with android:resizeableActivity="false" in the application tag and the launcher activity tag but it didn't help.

推荐答案

我已经找到了解决方案。

I have found a solution for it.

如果系统文字大小更改或显示大小设置为大(在Android Oreo以上),您的应用将正常运行(

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);

这篇关于如果设置-&gt ;,则禁用应用或活动缩放。显示->显示尺寸更改为大或小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆