首页 > 移动平台 > 详细

android状态栏 高度

时间:2014-10-31 13:56:15      阅读:292      评论:0      收藏:0      [点我收藏+]
private static int getStatusHeight(Context context){

        int statusHeight = 0;

        Rect localRect = new Rect();

        ((Activity) context).getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);

        statusHeight = localRect.top;

        if (0 == statusHeight){

            Class<?> localClass;

            try {

                localClass = Class.forName("com.android.internal.R$dimen");

                Object localObject = localClass.newInstance();

                int i5 = Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());

                statusHeight = context.getResources().getDimensionPixelSize(i5);

            } catch (Exception e) {

                e.printStackTrace();

            } 

        }

        return statusHeight;

    }

android状态栏 高度

原文:http://my.oschina.net/u/1781028/blog/339188

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