使用方法如下:

Point point = getNavigationBarSize(this);bottomHeight = point.y; if (bottomHeight > 0) {     //有NavigationBar }
public static Point getNavigationBarSize(Context context) {        Point appUsableSize = getAppUsableScreenSize(context);        Point realScreenSize = getRealScreenSize(context);        // navigation bar on the right        if (appUsableSize.x < realScreenSize.x) {            return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);        }        // navigation bar at the bottom        if (appUsableSize.y < realScreenSize.y) {            return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);        }        // navigation bar is not present        return new Point();    }    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)    public static Point getAppUsableScreenSize(Context context) {        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);        Display display = windowManager.getDefaultDisplay();        Point size = new Point();        display.getSize(size);        return size;    }    public static Point getRealScreenSize(Context context) {        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);        Display display = windowManager.getDefaultDisplay();        Point size = new Point();        if (Build.VERSION.SDK_INT >= 17) {            display.getRealSize(size);        } else if (Build.VERSION.SDK_INT >= 14) {            try {                size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);                size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);            } catch (IllegalAccessException e) {            } catch (InvocationTargetException e) {            } catch (NoSuchMethodException e) {            }        }        return size;    }

更多相关文章

  1. android SpannableString使用详解
  2. android studio 使用getActionBar返回NULL
  3. Android调用第三方App
  4. Android(安卓)使用广播(BroadcastReceiver)传递数据
  5. Android中ContextMenu的使用
  6. Android之使用Activity与Fragment通信
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. 电脑用户需要了解的Win7与Win10系统知识
  2. 外企抵制新疆棉 我国纺织企业如何寻求化
  3. clickhouse安装配置
  4. Centos7配置DR模式的LVS
  5. Mysql主从复制
  6. 《吊打面试官》系列-ConcurrentHashMap &
  7. 神经元是如何组成神经网?
  8. 教你轻松构建一个可以泡妞的 app
  9. 浅析tomcat8+memcached session共享
  10. 只需 2 步,定位集成融云时的崩溃与错误 -