Kevik Kevik - 7 months ago 87
Android Question

How to get height and width of navigation bar programmatically

the black navigation bar on the bottom of the screen is not easily removable in Android, It has been part of Android since 3.0 as a replacement for hardware buttons.

it is shown here in the pic.

how can I get the size of the width and height of this UI element in pixels? There has to be some code for this. Any ideas?

System Bar


Try below code:

Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
    return resources.getDimensionPixelSize(resourceId);
return 0;