屏幕相关

public Point getScreenSize(Context context) {
Point point = new Point();
WindowManager windowManager = (WindowManager) context.getSystemService(
Context.WINDOW_SERVICE);
//不含虚拟按键
//windowManager.getDefaultDisplay().getSize(point);
//包含虚拟按键
windowManager.getDefaultDisplay().getRealSize(point);
//屏幕宽度
int height = point.y;
//屏幕高度
int width = point.x;
LogUtil.d(TAG + "test() width:" + width + " height:" + height);

return point;
}
上一篇:android.view.WindowManager$BadTokenException: Unable to add window


下一篇:Window, WindowManager和WindowManagerService之间的关系