place MaterialDrawer above actionbar

729 Views Asked by At

How I can put MaterialDrawer menu above ActionBar? Now, when I open MaterialDrawer menu, my ActionBar is on top of it. Is there is any thing like Z-index in CSS? :D My application style:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
  <style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/ActionBar</item>
  </style>
  <style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar">
    <item name="background">@color/yellow_dark</item>
  </style>
</resources>

My MaterialDrawer initialization code:

DrawerBuilder().withActivity(activity).addDrawerItems(...).withSelectedItem(-1).withTranslucentStatusBar(false).withActionBarDrawerToggle(false).build()
1

There are 1 best solutions below

0
On BEST ANSWER

As already noted by @igor_rb this is only possible if you switch from an ActionBar to a Toolbar.

See the following already answered issues at github https://github.com/mikepenz/MaterialDrawer/issues/523 https://github.com/mikepenz/MaterialDrawer/issues/522 https://github.com/mikepenz/MaterialDrawer/issues/333

Switching to a Toolbar is really easy.


Use an AppCompatActivity Define the Toolbar within your layout

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:elevation="4dp" />

Set the Toolbar as SupportActionBar

// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Done