您的位置:首页 > 移动开发 > Android开发

获取Android屏幕总结

2016-05-22 11:01 423 查看
获取屏幕的大小

DisplayMetrics dm=new DisplayMetrics();

dm=context.getResource.getDisplayMetrics();

int width=dm.widthPixels;

int height=dm.heightPixels;

如果是获取一个窗口的大小

getWindosManager.getDefaluDisplay.getMetrics(dm);

获取状态栏的高

Rect frame=new Rect();

activity.getWindow().getDecoreView().getWindowVisableDisplayFrame(frame);

int height=frame.top;

获取状态栏和标题栏的高度

activity.getWindow.findViewById(Window.ID_ANDROID_CONTENT).getTop();

让屏幕全屏显示

getwindowManager.setflag(WindowManager.LayoutParams.FLAG_FULLSCREAN,WindowManager.LayoutParams.FLAG_FULLSCREAN);

让屏幕无标题栏

requestwindowfeature(Window.FEATURE_NOTITLE);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  屏幕大小 getwindow