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?
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.