实用获取Android状态栏的方法

Posted wx_962464

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实用获取Android状态栏的方法相关的知识,希望对你有一定的参考价值。

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状态栏的方法

以上是关于实用获取Android状态栏的方法的主要内容,如果未能解决你的问题,请参考以下文章