No drawer view found with gravity RIGHT (Android achieves slide menu from the RIGHT) solution: drawerandroid
The Code is as follows:
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:minHeight="?attr/actionBarSize"/> <android.support.v4.widget.DrawerLayout android:id="@+id/dl_home" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/dl_container" android:layout_width="match_parent" android:layout_height="match_parent"/> <LinearLayout android:id="@+id/dl_menu" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="end" android:background="@color/white" android:orientation="vertical"/> </android.support.v4.widget.DrawerLayout>
mToolbar = (Toolbar) findViewById(R.id.toolbar); dlHome = (DrawerLayout) findViewById(R.id.dl_home); drawerToggle = new ActionBarDrawerToggle(this, dlHome, mToolbar, 0, 0); drawerToggle.syncState();
Problem description:
You can use Toolbar, DrawerLayout, and ActionBarDrawerToggle to implement the slide menu. It is okay to click the button to implement slide on the left, but it is changed to slide on the right.
Error: No drawer view found with gravity LEFT
Solution: Add a listener for the mToolbar menu button. The specific implementation method is as follows:
mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (dlHome.isDrawerOpen(GravityCompat.END)) { dlHome.closeDrawers(); } else { dlHome.openDrawer(Gravity.END); } } });
The problem is solved.