First of thanks for this awesome library :+1:
So.. I wanted to implement something similar to the I/O 2015 preview app.
https://dl.pushbulletusercontent.com/ZZ7V2GsWeZSFTPgg0mcQ66BHJAIeOaYm/Screenshot_2015-05-13-03-11-25.png
But on my case when I add only 1 drawer with Gravity.RIGHT the hamburger icon still appears on the left... It also causes the app to crash if I press it.
I've seen your example with multi-drawer but I could not find a example with only a single drawer on the right.
@fnk0 the MaterialDrawer library will create a DrawerLayout as you would to. If you set the gravity it is just the DrawerLayout. This has nothing to do with the ActionBarDrawerToggle or the Toolbar. (It has just a method to simplify the ActionBarDrawerToggle usage)
The screenshot just shows a normal MenuItem on the right, so just handle the open and close of the drawer manually if you click this menu item. result.openDrawer()
About the exception you get. Can you post a Stacktrace please?
Ok i found your FC. It is because the ActionBarDrawerToggle (which is created by Android and included in the support libs) won't handle a different Drawer than a LEFT sided Drawer. This means you have to handle the ActionBarDrawerToggle, or to be more specific the icon and the navigation up there, on your own. To do this just don't pass the Toolbar to the MaterialDrawer and handle it as you would with any other DrawerLayout.
Here the FC. You can see the message on the top.
No drawer view found with gravity LEFT
java.lang.IllegalArgumentException: No drawer view found with gravity LEFT
at android.support.v4.widget.DrawerLayout.openDrawer(DrawerLayout.java:1322)
at android.support.v7.app.ActionBarDrawerToggle.toggle(ActionBarDrawerToggle.java:289)
at android.support.v7.app.ActionBarDrawerToggle.access$100(ActionBarDrawerToggle.java:65)
at android.support.v7.app.ActionBarDrawerToggle$1.onClick(ActionBarDrawerToggle.java:201)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Thank you @mikepenz, sorry I didn't sent the stack trace. I made the issue and then I went to bed. Thanks for the explanation. I did taught about adding the widget on the toolbar and handling as you said I just wasn't sure if the library offered a solution out of the box for that.
Thanks for the explanation.
@fnk0 no problem
Hello u, i have same issue, and i fix it bellow:
toolbar = (Toolbar) findViewById(R.id.tool_bar);
Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout);
mDrawerToggle = new ActionBarDrawerToggle(this,Drawer,toolbar,R.string.openDrawer,R.string.closeDrawer){
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
}; // Drawer Toggle Object Made
Drawer.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (Drawer.isDrawerOpen(Gravity.RIGHT)) {
Drawer.closeDrawer(Gravity.RIGHT);
} else {
Drawer.openDrawer(Gravity.RIGHT);
}
}
});
yes, it's work, i'm fix this bug in 5hour :( but i'm very happy when resolve it. ^^
thanks & good luck
@ssPerman01 thank you dear friend , i was same problem and your idea resolved it :)
@ssPerman01 it's work ....
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:layoutDirection="rtl">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
thanks @ssPerman01
@alicompu : what you did works, but it changes the layout from right to left, which would mean handling all the views and how they are displayed to make them look like "left to right"
thanks @ssPerman01
hi first tnx for this awesome lib
i want when i change langueg ,my drawer update rtl or tlr.
how do i do?
hi first tnx for this awesome lib
i want when i change langueg ,my drawer update rtl or tlr.
how do i do?
i have this question too i need persian right to left toolbar icon and menu too
Most helpful comment
Hello u, i have same issue, and i fix it bellow:
yes, it's work, i'm fix this bug in 5hour :( but i'm very happy when resolve it. ^^
thanks & good luck