本文介绍了最小宽度布局。臭虫的Nexus 7?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用布局-swdp限定符我得到的结果示于附件。西南预选赛的解释是:最小尺寸必须等于或大于预选赛大。这似乎并不与Nexus 7(4.2.1运行)工作。我是无所适从最小宽度预选赛做或者是N7报告错误?

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?

要重现我的测试情况下,我有很多布局swdp文件夹。每个有2个文本框。第一只是指出它在哪些文件夹下低于code:

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

推荐答案

好吧,这似乎是一个ICS臭虫,它不准确的报告整个屏幕,因为它考虑到铬的像素数。

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对ICS 返回不正确像素屏幕尺寸

Android DisplayMetrics returns incorrect screen size in pixels on ICS

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

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.

这篇关于最小宽度布局。臭虫的Nexus 7?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:56