Shahood ul Hassan
Shahood ul Hassan

Reputation: 789

How to implement a navigation drawer with transparent status bar with separate toolbars for each fragment?

I'm trying to implement a navigation drawer with transparent status bar. Second requirement is to have separate toolbars for each fragment. Third is that the result of this implementation looks the same on v19 & v21+ devices. I have created a sample app to demonstrate the problems I'm facing in this regard and it can be downloaded from this dropbox link, in order to have a look at the complete code. For this implementation I've taken help from cheesesquare sample app with certain modifications after researching a bit on the net.

Following are the problems:

V19:

1) Part of the toolbar hides behind the status bar in each fragment although I've used android:fitsSystemWindows="true" in the DrawerLayout of activity_main.xml: v19 toolbar behind status bar

2) Status bar is not transparent (as shown in above image) although I've used <item name="android:windowTranslucentStatus">true</item> in v19\styles.xml

3) Navigation drawer is not drawing behind the status bar: v19 with open drawer

V21+:

1) Status bar is not transparent although I've used the following in v21\styles.xml. It is of a grey color which I have not defined:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>

v21 non-transparent status bar

However, navigation drawer is being drawn rightly behind the status bar: v21 with open drawer

So, in the end, I'm unable to get the same look on both devices, also not able to get the transparent status on either and on one, navigation drawer is not drawing behind the status bar.

Kindly have a close look at it and suggest how I can fix this rather annoying issue. I've read a lot of material including relevant SO questions but couldn't fix this issue. In the end, I tried to follow the above-mentioned cheesesquare example but still I'm not getting what I wanted. And yeah, the only major difference I could find between my example and cheesesquare is that it is creating just one toolbar and that too in main activity.

Any help would be a great help!

Upvotes: 0

Views: 218

Answers (1)

Parth Patel
Parth Patel

Reputation: 891

From here you can reach to Navigation Drawer Activity. Provided by Android Studio.

Do right click on your package name. Select Navigation Drawer Activity option. (like below image is showing)

Create Navigation Drawer Activity

Give the name to your Activity.

Give Name to an Activity

Your Navigation Drawer will be created.

Upvotes: 0

Related Questions