Search code examples
androidnavigationbaroverlapslidingmenu

Android navigation bar covers bottom of screen


For an Android app that uses Jeremy Feinstein's SlidingMenu and targets API level 29, a problem has recently been noted on 2 devices (Samsung Galaxy A01 and Samsung Galaxy Note20 Ultra, running Android 11) whereby the content at the bottom of the screen is covered by the navigation bar.

The only thing that has made a difference on the 2 affected devices is adding this in the sliding menu constructors:

if (Build.VERSION.SDK_INT >= 21) {
    setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}

or using SlidingMenu.SLIDING_CONTENT instead of SlidingMenu.SLIDING_WINDOW.

One or the other of these changes resolves the issue on the 2 devices, but on devices for which the problem has never occurred (Pixel 2, Moto X4, Nexus 6, etc., running Android 9, 10, 11) there is then a white gap at the bottom between the bottom of the screen content and the navigation bar.

The 2 devices with the issue are reported to have displayed all screens correctly at an uncertain point in the past, possibly around January, around which point there was no update to the app. They belong to the same user, who reports he does not have this problem with any other apps, and for this app, only on screens that are displayed in Fragments with a custom ActionBar (removing the custom ActionBar does not help).

Other things that were tried that do not help, in no particular order, include:

So the question is, how can the problem be fixed for both the devices with the issue and for those without it? Let me know if there is any code I should post.


Solution

  • The problem was a navigation bar height calculation, which had to be adjusted for devices with display cutouts, thanks to @JohnLord for picking up on that difference.