StatusBar
1 2 3 4 5 | int statusBarHeight = 0; int resId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resId > 0) { statusBarHeight = getResources().getDimensionPixelSize(resId); } |
ActionBar
1 2 3 4 5 6 | int actionBarHeight = 0; final TypedArray styledAttributes = getTheme().obtainStyledAttributes( new int[] { android.R.attr.actionBarSize } ); actionBarHeight = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle(); |
NavigationBar
1 2 3 4 5 | int navigationBarHeight = 0; int resId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); if (resId > 0) { navigationBarHeight = getResources().getDimensionPixelSize(resId); } |