public static int getStatusBarHeight(Context context){
        Class<?> c = null;
        Object obj = null;
        Field field = null;
        int x = 0, statusBarHeight = 0;
        try {
            c = Class.forName("com.android.internal.R$dimen");
            obj = c.newInstance();
            field = c.getField("status_bar_height");
            x = Integer.parseInt(field.get(obj).toString());
            statusBarHeight = context.getResources().getDimensionPixelSize(x);
        } catch (Exception e1) {
            e1.printStackTrace();
        } 
        return statusBarHeight;
    }

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2021-09-16
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
相关资源
相似解决方案