我如何让 android 模拟器报告特定的屏幕尺寸

发布于 2024-12-12 18:04:34 字数 1688 浏览 0 评论 0原文

我正在尝试模拟 HTC Flyer,为了做到这一点,我需要模拟器自我报告为“大”屏幕尺寸。我已指定分辨率和正确的 dpi,但它报告为“xlarge”。 Android 文档 ( http://developer.android.com/guide/practices/screens_support .html#range )指定它应该是“xlarge”,但 HTC Flyer 设备却说它是“large”。这是一些带有一些数字的调试输出:

flyer device 

DisplayMetrics{density=1.0, width=600, height=1024, scaledDensity=1.0, xdpi=169.99738, ydpi=169.33333}, densityDpi, 160, density, 1.0, screen size, large,

flyer emulator

DisplayMetrics{density=1.0, width=600, height=1024, scaledDensity=1.0, xdpi=160.0, ydpi=160.0}, densityDpi, 160, density, 1.0, screen size, xlarge,

注意“屏幕尺寸”。其他一切都相同,但设备报告“large”,模拟器报告“xlarge”。有没有办法让模拟器报告“大”?

这是给我输出的java:

 DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int screenLayout = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    String screenLayoutStr;
    switch (screenLayout){
        case Configuration.SCREENLAYOUT_SIZE_SMALL:
            screenLayoutStr = "small";
            break;
        case Configuration.SCREENLAYOUT_SIZE_NORMAL:
            screenLayoutStr = "normal";
            break;
        case Configuration.SCREENLAYOUT_SIZE_LARGE:
            screenLayoutStr = "large";
            break;
        case 4:
            screenLayoutStr = "xlarge";
            break;
        default:
            screenLayoutStr = "unknown: " + screenLayout;
    }
    LogIt.d(this,metrics,"densityDpi",metrics.densityDpi,"density",metrics.density,"screen size",screenLayoutStr);

I am trying to emulate the HTC Flyer and in order to do that I need the emulator to self-report as "large" screen size. I have specified the resolution and the correct dpi but it reports as "xlarge". The android documentation ( http://developer.android.com/guide/practices/screens_support.html#range ) specifies that it should be "xlarge" but the HTC Flyer device says it's "large". Here is some debug output with some numbers:

flyer device 

DisplayMetrics{density=1.0, width=600, height=1024, scaledDensity=1.0, xdpi=169.99738, ydpi=169.33333}, densityDpi, 160, density, 1.0, screen size, large,

flyer emulator

DisplayMetrics{density=1.0, width=600, height=1024, scaledDensity=1.0, xdpi=160.0, ydpi=160.0}, densityDpi, 160, density, 1.0, screen size, xlarge,

notice the "screen size". Everything else is equal but the device reports "large" and the emulator "xlarge". Is there a way to make the emulator report "large" instead?

Here is the java that gave me the output:

 DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int screenLayout = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    String screenLayoutStr;
    switch (screenLayout){
        case Configuration.SCREENLAYOUT_SIZE_SMALL:
            screenLayoutStr = "small";
            break;
        case Configuration.SCREENLAYOUT_SIZE_NORMAL:
            screenLayoutStr = "normal";
            break;
        case Configuration.SCREENLAYOUT_SIZE_LARGE:
            screenLayoutStr = "large";
            break;
        case 4:
            screenLayoutStr = "xlarge";
            break;
        default:
            screenLayoutStr = "unknown: " + screenLayout;
    }
    LogIt.d(this,metrics,"densityDpi",metrics.densityDpi,"density",metrics.density,"screen size",screenLayoutStr);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文