Window window = getWindow();
lp = ();
= .MATCH_PARENT;
= .MATCH_PARENT;
// 如果将高度设置为MATCH_PARENT,那么就会出现状态栏变黑的问题
解决办法:
动态的去计算手机高度
getWindow().setLayout((.MATCH_PARENT), ()- ());
/**
* 获取屏幕高度
*
* @return 屏幕高度
*/
public static int getScreenHeight() {
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
return ().getHeight();
}
/**
* 获取状态栏高度
*
* @return 状态栏高度
*/
public static int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}