现在的位置: 首页 > 综合 > 正文

android 得到屏幕尺寸 状态栏尺寸 标题栏尺寸

2013年10月03日 ⁄ 综合 ⁄ 共 493字 ⁄ 字号 评论关闭

屏幕尺寸:

WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
int  screenWidth = wm.getDefaultDisplay().getWidth();
  
  
int  screenHeight = wm.getDefaultDisplay().getHeight();

状态栏尺寸:

Rect frame = new Rect();  

getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);  

int statusBarHeight = frame.top;  

标题栏尺寸:

int contentTop = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();  

//statusBarHeight是上面所求的状态栏的高度   

int titleBarHeight = contentTop - statusBarHeight  

 

  
 

抱歉!评论已关闭.