Android screen metrics problem - height, width, dpi and textsize
I have two emulators. If I do a
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
Then for one dm.densityDpi (and dm.xpdi and dm.ypdi) is 160. dm.heightpixels in Landscape mode is 800. The skin is the standard wxga, running Android 3.1.
The other emulator has dm.densityDpi of 240. dm.heightpixels in Portrait mode is also 800. The skin is the standard wvga800, running Android 2.3.3 (a开发者_如何学JAVAnd also for 2.1.1 with the same specs).
If I have a TextView tv, and do a:
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
On the wxga landscape screen, it displays fine. On the wvga800 portrait screen, the words go off the screen, horizontally. The screen is too small to display all the resulting from top to bottom, not left to right.
This doesn't make sense to me. Why would an emulator with a smaller dpi be able to display more text, when heightPixels is the same for both? I would have assumed the reverse would be true.
The Scaled density settings on the emulators were different.
I too had a same problem, try this you may get the proper answer Screen Resolution Problem
精彩评论