android获取屏幕的高度和宽度用到WindowManager这个类,两种方法:
1
、WindowManager
wm = (WindowManager) getContext()
.getSystemService(Context.WINDOW_SERVICE);
int
width
= wm.getDefaultDisplay().getWidth();
int
height
= wm.getDefaultDisplay().getHeight();
2
、WindowManager
wm =
this
.getWindowManager();
int
width
= wm.getDefaultDisplay().getWidth();
int
height
= wm.getDefaultDisplay().getHeight();
//设置窗体全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//设置窗体始终点亮
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//设置窗体背景模糊
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);