Trying to make Status bar and Navigation bar translucent, not transparent

Viewed 91

I'm trying to make my first app for a school project. I got the status bar translucent at times by following other people questions and answers but the nav just goes grey but with no contents from the activity BUT the navigation drawer draws below both status and navigation bar, how can I make the activity to draw below status and nav bar as well?

enter image description here

enter image description here

code for image 2 is, under onCreate:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,

WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

And I tried with android:fitsSystemWindows="true" and without, kinda hard to understand it all already.

1 Answers

Pretty much solved by adding these two lines in styles.xml

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

Not the most elegant because I don't have a proper toolbar? I think. I need to put android:layout_marginTop="24dp" in activity_main.xml and pretty much everywhere else where I may have buttons at the top of the app.

Related