gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:57:27 24 4
gpt4 key购买 nike

当使用 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;
}

enter image description here

最佳答案

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

Android DisplayMetrics returns incorrect screen size in pixels on ICS

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

关于android - 最小宽度布局。 Nexus 7 中的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14616881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com