先获取状态栏的高度:
statusHeight
方法如下:
<span style="white-space:pre"> </span>Class<?> c = null;
Object obj = null;
java.lang.reflect.Field field = null;
int x = 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());
statusHeight = IFGAppParams.getAppContext().getResources().getDimensionPixelSize(x);
return statusHeight;
} catch (Exception e)
{
e.printStackTrace();
}
return statusHeight;
然后对DecorView 增加statusHeight高度的同时,向上滑动statusHeight即可:
<span style="white-space:pre"> </span>getWindow().setLayout(LayoutParams.MATCH_PARENT, ScreenUtil.height
+ statusHeight);
getWindow().getDecorView().scrollTo(0, statusHeight);