Question

in my app I am using a full screen layout, meaning that the screen goes beyond the on screen buttons (like the ones on the nexus devices).

If I now put buttons and other elements at the bottom of my layout, they will interfere with the navigation bar.

How can I make this not happen? Is there any way to specify that my ui elements are put above the on screen buttons while maintaining the full screen experience?

Was it helpful?

Solution

As noted in the Translucent System Bars, you can add android:fitsSystemWindows="true" (documentation) to ensure that those elements are not placed over system navigation areas.

OTHER TIPS

Android Developers Training has a guide on how to use Immersive Full-Screen Mode. It hides the bottom system bar and allows for ui elements to be used in that area instead. If you want to shift your buttons up, the bottom system bar occupies a certain amount of pixels based on the device screen resolution. Below is some code that will return the number of pixels that the bar occupies, and you can use that number to move your ui elements.

public int getStatusBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");

    if (resourceId > 0) {
        result = getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top