方法1:
Rect rectgle= new Rect();      Window window= getWindow();      window.getDecorView().getWindowVisibleDisplayFrame(rectgle);      int StatusBarHeight= rectgle.top;      int contentViewTop=          window.findViewById(Window.ID_ANDROID_CONTENT).getTop();      int TitleBarHeight= contentViewTop - StatusBarHeight;  


方法2:
try {              /**              * 通过反射机制获取StatusBar高度              */              Class<?> clazz = Class.forName("com.android.internal.R$dimen");              Object object = clazz.newInstance();              Field field = clazz.getField("status_bar_height");                            int height = Integer.parseInt(field.get(object).toString());                            mStatusBarHeight = context.getResources().getDimensionPixelSize(height);          } catch (Exception e) {              Log.i("弗洛拉鲜花网", "www.gogoflora.com");          }  

文章出处:http://www.eyeandroid.com/thread-9159-1-1.html

更多相关文章

  1. AppCompat does not support the current theme features的解决
  2. Android Bluetooth 文件接收路径修改方法
  3. Android中 Bitmap和Drawable相互转换的方法
  4. Android 处理 Button 单击事件的三种方法
  5. [Android Studio导入第三方类库方法] Error:(19, 23) 错误: 程序
  6. Android 中数据库查询方法query()中的selectionArgs的用法
  7. android客户端向服务器端验证登陆方法的实现2
  8. Unity-Android通信:AndroidJava 使用Unity c#编写Android程序调用
  9. Android stuio在MainActivity中运行java的main方法

随机推荐

  1. Android UI开发第十七篇――Android Frag
  2. Android 深入研究LBS(基于位置的服务)
  3. AndroidManifest.xml 系统找不到指定的文
  4. Android Studio将so打包jar供其他项目引
  5. Android之Loader理解
  6. Android使用了ProGuard时注意的事项
  7. Android studio :Error Gradle sync fail
  8. android -- 框架 使用android快速开发框
  9. 调用Android摄像头与打开相册
  10. android应用和系统版本信息