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