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