private boolean hasNavigationBar() { Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // 获取设备的硬件屏幕高度 display.getRealMetrics(displayMetrics); int realHeightPixels = displayMetrics.heightPixels; int realWidthPixels = displayMetrics.widthPixels; // 内容区域的屏幕高度 displayMetrics = new DisplayMetrics(); display.getMetrics(displayMetrics); int heightPixels = displayMetrics.heightPixels; int widthPixels = displayMetrics.widthPixels; int dHight = realHeightPixels - heightPixels; int dWidth = realWidthPixels - widthPixels; return dHight > 0 || dWidth > 0; } return false; }