I want to get real resolution of screen on Android Honeycomb.
Here's my code
Display display = getWindowManager().getDefaultDisplay();
int w = display.getWidth();
int h = display.getHeight();
My device is Asus Transformer TF101 with size are 1280x800.
But above code make w = 1280 and h = 752 (That i want is 800 not 752).
I know h < 800 because it's subtracted for status bar.
Have any way to get real height of screen?
Many thanks!
You can extend a layout which will be your top layout (which will be set to fill_parent width and height) and override the onSizeChange(int width, int height, int oldwidth, int oldheight). The width and height is the real width and height of your display.
Use the DisplayMetrics structure, describing general information about the display, such as its size, density, and font scaling.
The code used to get the display's height is as follows:
It's supposed to return the absolute height of the display, in pixels.
I have a Xoom in hand, and used
getWindowManager().getDefaultDisplay()
to retrieve the dimension, it returns me 1280 x 800 which is the full screen size. I wonder how to get the resolution minus navigation bar with API before version 3.0.This is another viable solution for measuring the screen size (API 11+):
Where the ABDimension class contains six integers labeled nWidth, nHeight, nMarginLeft, nMarginTop, nMarginRight and nMarginBottom. This version accounts for common Android decor components like the TitleBar/StatusBar.