开发者

Giving Wrong Density value on Android Xoom Tablet with OS 3.1

On Xoom tablet i am getting density value 1.0. Is there anything i have missed in manifest file to support 3.0 or greater os devices? Below is the code snippet to print the density value on tablet.

    System.out.println("******==="+getResources().getDisplayMetrics().density
            +"===widht=="+getResources().getDisplayMetrics().widthPix开发者_StackOverflow中文版els
            +"===height=="+getResources().getDisplayMetrics().heightPixels
            +"====="+getResources().getDisplayMetrics().toString()); 

I have also added all supported screens set to true but still getting density value wrong.

<supports-screens android:resizeable="true" android:smallScreens="true"
        android:normalScreens="true" android:largeScreens="true" 
        android:xlargeScreens="true" android:anyDensity="true" />

Anybody have any ideas on this?


Have a look to the Android doc density:

The logical density of the display. This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen), providing the baseline of the system's display. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.

This value does not exactly follow the real screen size (as given by xdpi and ydpi, but rather is used to scale the size of the overall UI in steps based on gross changes in the display dpi. For example, a 240x320 screen will have a density of 1 even if its width is 1.8", 1.3", etc. However, if the screen resolution is increased to 320x480 but the screen size remained 1.5"x2" then the density would be increased (probably to 1.5).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜