/** 
     * 用于获取状态栏的高度。 
     * @return 返回状态栏高度的像素值。 
     */  
    private int statusBarHeight;//状态栏的高度,注意不是标题栏
    private int getStatusBarHeight() {  
        if (statusBarHeight == 0) {  
            try {  
                Class<?> c = Class.forName("com.android.internal.R$dimen");  
                Object o = c.newInstance();  
                java.lang.reflect.Field field = c.getField("status_bar_height");  
                int x = (Integer) field.get(o);  
                statusBarHeight = getResources().getDimensionPixelSize(x);  
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
        }  
        return statusBarHeight;  
    } 

 例子:窗体的使用,悬浮窗,仿360手机卫士2

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
猜你喜欢
  • 2021-09-03
  • 2021-11-28
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案