Resolve the conflict between slidingmenu and swipebacklayout right slide events

Source: Internet
Author: User

Swipebacklayout slide to the right to close the current activity. slidingmenu slide to the right to open the menu part. In the same activity, when slidingmenu is in the open state, sliding to the right will give priority to swipebacklayout. As a result, most of the events on the screen are menus, A small part is that the current activity is directly closed when the activity content is used. Obviously, this is not what the user is willing to see (the correct operation scenario is: When slidingmenu is enabled, slide right first, the corresponding slidingmenu is closed slowly, and then the current activity is closed in response to swipebacklayout. If slidingmenu is closed, swipebacklayout is directly returned ).

Considering that both slidingmenu and swipebacklayout have their own statuses, and to maximize coupling, you can perform the following processing (re-write dispatchtouchevent directly in the current activity, and set the available status of swipebacklayout Based on slidingmenu status ):

 1 @Override 2 public boolean dispatchTouchEvent(MotionEvent ev) { 3     if (menu.isMenuShowing()) { 4         if (mSwipeBackLayout.getEnableGesture()) { 5             mSwipeBackLayout.setEnableGesture(false); 6         } 7     } else { 8         if (!mSwipeBackLayout.getEnableGesture()) { 9             mSwipeBackLayout.setEnableGesture(true);10         }11     }12     return super.dispatchTouchEvent(ev);13 }

 

Resolve the conflict between slidingmenu and swipebacklayout right slide events

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.