使用方法如下:

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. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 【Android(安卓)开发教程】重写onKeyDown
  2. Android(安卓)Launcher 详解
  3. DirectionalViewPager支持横向和纵向的Vi
  4. Android字体00
  5. Android(安卓)stutdio2.2 启动模拟器出现
  6. GitHub上不错的Android开源项目(二)
  7. Android基础篇之AutoCompleteTextView
  8. 【OkHttp3源代码分析】(一)Request的execut
  9. android的日志输出和单元测试
  10. Android(安卓)2.3新增API - DownloadMana