Android取得StatusBa有効高さ
1263 ワード
方法1:
方法2:
記事の出典:
http://www.eyeandroid.com/thread-9159-1-1.html
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;
方法2:
try {
/**
* StatusBar
*/
Class<?> clazz = Class.forName("com.android.internal.R$dimen");
Object object = clazz.newInstance();
Field field = clazz.getField("status_bar_height");
int height = Integer.parseInt(field.get(object).toString());
mStatusBarHeight = context.getResources().getDimensionPixelSize(height);
} catch (Exception e) {
Log.i(" ", "www.gogoflora.com");
}
記事の出典:
http://www.eyeandroid.com/thread-9159-1-1.html