/*获取状态栏的高度,有时候出现popuwindow超出屏幕时,减去它,默认24dp*/ //获取顶部状态栏的高度 private int getStatusBarHeight() { Resources resources = MainActivity.this.getResources(); int resourceId = resources.getIdentifier("status_bar_height", "dimen","android"); int height = resources.getDimensionPixelSize(resourceId); Log.v("dbw", "Status height:" + height); return height; } //获取底部 navigationbar的高度 private int getNavigationBarHeight() { Resources resources = MainActivity.this.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height","dimen", "android"); int height = resources.getDimensionPixelSize(resourceId); Log.v("dbw", "Navi height:" + height); return height; }