android取高度

Rect rect = new Rect();
  getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
  int top = rect.top;  //状态栏高度
  View view = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
  int top2 = view.getTop();//状态栏标题校栏的总高度,top2-top 为标题高度
  int width = view.getWidth();     //用户区宽度
  int height = view.getHeight();  //用户区高度
  

Display mDisplay = getWindowManager().getDefaultDisplay();

int width = mDisplay.getWidth();     //屏幕宽度
int height = mDisplay.getHeight();  //屏幕高度

posted on 2014-04-21 15:41  strangeman  阅读(161)  评论(0编辑  收藏  举报

导航