Some Android applications still use the menu button functionality that was deprecated since 3.0. Many new phones (Nexus for instance) have software navigation buttons and this menu icon is appended to the navigation bar when an application uses it and has not defined an ActionBar.
To get usable screen dimensions in this scenario, I can subtract the notification bar from the total screen height:
DisplayMetrics dm = mContext.getResources().getDisplayMetrics();
int height = dm.heightPixels - getStatusBarHeight(mContext);
where getStatusBarHeight
is a function defined elsewhere.
However, if the phone has hardware navigation buttons, an extra navigation row is displayed by the application at the bottom, as shown in the attached picture.
In this case the previous solution does not work, since the added navigation bar needs to be subtracted.
I'm looking to write a general function that solves for both cases, returning the usable screen dimensions/coordinates by subtracting the software navigation bar and the notification bar. I want to avoid vendor/device specific checks.
There seems to be a way of solving this using getWindow().getDecorView().getWindowVisibleDisplayFrame(rectangle);
but which values are needed from the Window?