No drawer view found with gravity RIGHT (Android achieves slide menu from the RIGHT) solution: drawerandroid

Source: Internet
Author: User

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.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.