I am using MaterialDrawer library for adding a drawer to my activities. The activities must have translucent status bar. Like the picture below:
This is the top part of my activity, when the library has not added to it yet.
When I add a drawer using the library:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DrawerMenu.addTo(this);
}
}
And the DrawerMenu
helper class:
public class DrawerMenu {
public static void addTo(final Activity activity) {
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(activity)
.withHeaderBackground(R.drawable.drawer_header)
.addProfiles(
new ProfileDrawerItem()
.withName("Ashkan")
.withEmail("ashkan@sarlak.com")
.withIcon(ContextCompat.getDrawable(activity, R.drawable.profile_pic))
)
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
return false;
}
})
.build();
new DrawerBuilder()
.withActivity(activity)
.withAccountHeader(headerResult)
.addDrawerItems(new PrimaryDrawerItem().withName("Login"))
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
Toast.makeText(activity, "Login!!!", Toast.LENGTH_LONG).show();
return true;
}
})
.build();
}
}
I will get this result:
The status bar is obviously non translucent and activity content is not below it.
However when I open the drawer, it goes beneath the status bar:
Also this is the theme that I'm applying to the activity:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
</style>
What is the problem here?