When using the layout-swdp qualifiers I get the results as shown in the attachment. The sw qualifier is supposed to mean the smallest dimension must match or be bigger than the qualifier. This doesn't seem to work with the Nexus 7 (running 4.2.1). Am I confused about what smallest width qualifiers do or is the N7 reporting wrongly?
To reproduce my test case, I have many layout-swdp folders. Each has 2 textfield. The first just states which folders it's in. The next is the code below:
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;
}
Okay, this seems to be a bug in ICS where it doesn't accurate report the number of pixels of the entire screen as it taking into account the chrome.
Android DisplayMetrics returns incorrect screen size in pixels on ICS
So, my above display numbers are off as nexus 7 is 1280 x 800 and not 1280 x 736. Using the correct numbers, everything works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With