我正在尝试创建状态栏高度,它在2.3中成功运行。但是当我在4.0+上运行相同的代码时,它将返回0。
这是我正在使用的代码...
Rect rectgle= new Rect();
Window window= getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
int StatusBarHeight= rectgle.top;
int contentViewTop=
window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int TitleBarHeight= contentViewTop - StatusBarHeight;
Context context = getApplicationContext();
CharSequence text = "DETERMINED STATUSBAR HEIGHT - "+TitleBarHeight;
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
任何输入都很棒!