Android screen

For 720×1280 screen, title bar height=50, status bar height=50.  i.e. with both, content starts at y=100.

Below is the code to get the title bar height and status bar height.  Workable at Android 2.2. It only works after the screen is measured, i.e. not in onCreate.


--------------------------------
Rect rectangle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight = contentViewTop - statusBarHeight;
Log.d("", "StatusBar=" + statusBarHeight + ", TitleBar=" + titleBarHeight);

發表留言