在onCreate()中无法获得,必须在下面的方法中:

@Override

publicvoidonWindowFocusChanged(booleanhasFocus){

//TODOAuto-generatedmethodstub

super.onWindowFocusChanged(hasFocus);

getWindow().findViewById(Window.ID_ANDROID_CONTENT);

Displaydisplay=getWindowManager().getDefaultDisplay();

//屏幕高度

intheight=display.getHeight();

Rectframe=newRect();

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

//状态栏高度

intstatusBarHeight=frame.top;

}

更多相关文章

  1. Android getDecorView用途——屏幕截图
  2. 屏幕切换,保存内容
  3. 2011.07.20——— android 获得当前view在屏幕的坐标
  4. android 固定屏幕显示方向
  5. android屏幕旋转时,Activity不重新调用onCreate的方法
  6. android – 多屏幕适配相关

随机推荐

  1. Android中字体的处理
  2. Android(安卓)实现仿Window7图片预览窗格
  3. Android(安卓)WebView在系统进程中无法使
  4. Android(安卓)多行跑马灯 解决焦点抢占
  5. Android中短信的收发机制 发送短信 接收
  6. Android之SurfaceView实现视频播放
  7. 内存管理Memory Management in Android
  8. Android各个版本API的区别
  9. Android全屏(包含3种隐藏顶部状态栏及标题
  10. Android(安卓)SDK Manager无法下载包的问