状态栏:
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
rect.top即为状态栏的高度。
标题栏: getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
注意要在onWindowFocusChanged里用这个方法,否则很有可能是0;
状态栏:
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
rect.top即为状态栏的高度。
标题栏: getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
注意要在onWindowFocusChanged里用这个方法,否则很有可能是0;