root = (ViewGroup)findViewById(R.id.root);
root.post(new Runnable() {
public void run(){
Rect rect = new Rect();
Window win = getWindow();
win.getDecorView().getWindowVisibleDisplayFrame(rect);
int statusHeight = rect.top;
int contentViewTop = win.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleHeight = contentViewTop - statusHeight;
Log.w("dimens_tag", "title = " + titleHeight + " status bar = " + statusHeight);
}
});
3
solved How to get Android screen height minus status bar in pixel?