繁体   English   中英

最小宽度布局。 Nexus 7中的错误?

[英]smallest width layouts. bug in Nexus 7?

使用layout-swdp限定符时,我得到附件中显示的结果。 sw限定符应该表示最小维度必须匹配或大于限定符。 这似乎不适用于Nexus 7(运行4.2.1)。 我对最小宽度限定符的作用或N7错误报告感到困惑吗?

为了重现我的测试用例,我有许多layout-swdp文件夹。 每个都有2个文本字段。 第一个只是说明它所在的文件夹。接下来是下面的代码:

private CharSequence collectScreenStats() {
    StringBuilder str = new StringBuilder();
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int width = metrics.widthPixels;
    int height = metrics.heightPixels;
    int dpWidth = (int)(width / metrics.density);
    int dpHeight = (int)(height / metrics.density);
    str.append(Build.MANUFACTURER);
    str.append(" ");
    str.append(Build.MODEL);
    str.append("\n");
    str.append("Pixels: ");
    str.append(width);
    str.append(" x " );
    str.append(height);
    str.append("\nDp (px / density): ");
    str.append(dpWidth);
    str.append("dp x " );
    str.append(dpHeight);
    str.append("dp" );
    str.append("\nsmallest w: " + Math.min(dpWidth, dpHeight));
    str.append("\ndensity: ");
    str.append(metrics.density);
    str.append("\ndensityDpi: ");
    str.append(metrics.densityDpi);

    return str;
}

在此输入图像描述

好吧,这似乎是ICS中的一个错误,因为考虑到chrome,它无法准确报告整个屏幕的像素数。

Android DisplayMetrics在ICS上返回不正确的屏幕尺寸(以像素为单位)

因此,我的上述显示数字是关闭的,因为nexus 7是1280 x 800而不是1280 x 736.使用正确的数字,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM