最小宽度布局。Nexus 7存在问题?

5
使用layout-swdp限定符时,我得到的结果如附件所示。sw限定符应该意味着最小维度必须匹配或比限定符更大。但这似乎在Nexus 7(运行4.2.1)上无效。我是否对最小宽度限定符的作用有所困惑,或者N7报告错误?
要重现我的测试用例,我有许多layout-swdp文件夹。每个文件夹中都有两个文本字段。第一个只是说明它在哪个文件夹中。下一个是以下代码:
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;
}

enter image description here

1个回答

3

看起来这似乎是ICS中的一个错误,它没有准确地报告整个屏幕的像素数量,因为它考虑了chrome的影响。

Android DisplayMetrics返回ICS上不正确的屏幕像素大小

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接