首页 > 移动平台 > 详细

Android开发之获取状态栏高度

时间:2016-01-25 11:13:35      阅读:230      评论:0      收藏:0      [点我收藏+]

转自:http://blog.csdn.net/guolin_blog/article/details/16919859

获取状态栏的高度。

 1     private static int statusBarHeight;
 2     
 3     private int getStatusBarHeight() {
 4         if (statusBarHeight == 0) {
 5             try {
 6                 Class<?> c = Class.forName("com.android.internal.R$dimen");
 7                 Object o = c.newInstance();
 8                 Field field = c.getField("status_bar_height");
 9                 int x = (Integer) field.get(o);
10                 statusBarHeight = getResources().getDimensionPixelSize(x);
11             } catch (Exception e) {
12                 e.printStackTrace();
13             }
14         }
15         return statusBarHeight;
16     }

 

Android开发之获取状态栏高度

原文:http://www.cnblogs.com/liyiran/p/5156800.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!