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. Here is a picture:
How can I get the size of the width and the height of this UI element in pixels?
In my case where I wanted to have something like this:
I had to follow the same thing as suggested by @Mdlc but probably slightly simpler (targeting only >= 21):
It works on landscape too:
Edit The above solution does not work correctly in multi-window mode where the usable rectangle is not smaller just due to the navigation bar but also because of custom window size. One thing that I noticed is that in multi-window the navigation bar is not hovering over the app so even with no changes to DecorView padding we have the correct behaviour:
Note the difference between how navigation bar is hovering over the bottom of the app in these to scenarios. Fortunately, this is easy to fix. We can check if app is multi window. The code below also includes the part to calculate and adjust the position of toolbar (full solution: https://stackoverflow.com/a/14213035/477790)
Result on Samsung popup mode:
Tested code for getting height of navigation bar (in pixels):
Tested code for getting height of status bar (in pixels):
Converting pixels to dp:
Actually the navigation bar on tablets (at least Nexus 7) has different size in portrait and landscape so this function should look like this: