标签:
Class<?> c = null; Object obj = null; Field field = null; int x = 0, sbar = 0; try { c = Class.forName("com.android.internal.R$dimen"); obj = c.newInstance(); field = c.getField("status_bar_height"); x = Integer.parseInt(field.get(obj).toString()); sbar = getResources().getDimensionPixelSize(x); } catch(Exception e1) { loge("get status bar height fail"); e1.printStackTrace(); }
下面代码不要放在onCreate中,否则获取状态栏高度为0
Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top;
标签:
原文地址:http://www.cnblogs.com/yydcdut/p/4470196.html