Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Navigation Bar overlaying my view

I have an issue with Android Navigation Bar on devices like Nexus etc. Simply at all devices, which do not have the hardware menu button.

Let me explain the issue in more details.

I have an application where there are 3 parts. Content, ActionBar and bottom panel with a SeekBar.

enter image description here

ActionBar and bottom panel with a SeekBar are overlaying the content. Everytime I click on the content the ActionBar and bottom panel with a SeekBar disappear. Which works exactly the way it has to work. Here is a fragment of a code I use for hiding system UI:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {                
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);
} else {                
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    actionBar.hide();
}
findViewById(R.id.read_book_bottom_bar).setVisibility(View.GONE);

In onCreate method of my activity, I have this piece of code:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {            
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);          
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN);   
}

However, when I launch the application on devices with Android Navigation Bar, there is a problem with displaying the bottom panel with a SeekBar. Simply, the Android Navigation Bar overlays the bottom panel with a SeekBar. Here is a screenshot:

enter image description here

But everytime I click on the content, the Android Navigation Bar disappears along with the ActionBar and the bottom panel with the SeekBar. So, the issue is, that everytime somebody would like to use the bottom panel with the SeekBar on devices like NEXUS, he/she would not be able to use it, because it's hidden under the Android Navigation Bar.

Could anybody help me with solving this issue? Thank you all in advance.

like image 264
PetrS Avatar asked Aug 24 '14 11:08

PetrS


People also ask

How do I change the navigation bar style in Android?

There are two ways to style the navigation bar depends on how you create it. One is using the XML style file if you create the navigation bar from XML. The other one is to change it using code.

What is Android overlay?

An overlay is one of the primary surfaces for app content. Overlays are different from complications or Tiles, which are glanceable representations of app content. Overlays display more information and support richer interactivity.

How do you make the navigation bar visible?

From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen.


1 Answers

Finally, I solved it with attribute fitsSystemWindows = true.

like image 174
PetrS Avatar answered Oct 18 '22 08:10

PetrS