Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing content behind Navigation Bar

Tags:

android

I'm currently working on something where I want the status and navigation bars to be transparent, with the content going behind them. Currently, I have the bars set to @android:color/transparent in styles.xml and am able to get the content behind the status bar with this code:

getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                   View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            );

However I am still struggling to get it behind the nav bar. Any help appreciated.

Thanks, Josh

like image 309
Joshua Feltimo Avatar asked Aug 09 '16 23:08

Joshua Feltimo


People also ask

How do I add a background to my navigation bar?

Use any of the . bg-color classes to add a background color to the navbar. Tip: Add a white text color to all links in the navbar with the . navbar-dark class, or use the .

How do I make content go under navbar?

Simply, use the z-index attribute. The default is 0, so if the other elements have not been changed, you can just set the z-index of the nav-bar to 1 and it will display above all other elements. ** NOTE: For z-index to work, you must use positioning. You need to rewrite your page, properly.

How do I make the navigation bar background transparent?

Creating a transparent navbar is very easy - just don't add a color class . bg-* to the navbar. In this case, the Navbar will take the color of the parent's background color.


2 Answers

You need:

getWindow()
  .setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Check out the answer here:

Showing content behind status and navigation bar

like image 118
droid256 Avatar answered Nov 15 '22 08:11

droid256


Try to add these in your activity's style.xml:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>

hope this can help.

like image 28
L. Swifter Avatar answered Nov 15 '22 08:11

L. Swifter