I'm working on a cross-platform app which has been ported to Android. Due to its non-Android heritage it doesn't make extensive use of Android UI elements – the main app window is one single View
.
I would like to implement translucent system (status and navigation) bars, as supported from KitKat onwards, while ensuring that UI elements inside the main View
are not obstructed by them.
This answer shows how to get the default height for these bars (there is also navigation_bar_height_landscape
for navigation bar height in landscape mode, and navigation_bar_width
for the width of a vertical navigation bar). But these are only the system's default sizes and contain no information if the navigation bar is currently being shown, and whether it is showing at the right or on the bottom edge of the screen.
The other answers I have found so far probably work fine for non-translucent system bars: they simply compare total screen size to the size of the main app view, and the difference is the space occupied by the system bars. However, with translucent system bars, the size difference is zero and this approach won't work.
How can I reliably determine if the navigation bar is being displayed, and in which position?