DrawerLayout prevents call of MainActivity.onTouchEvent()

前端 未结 3 1259
梦谈多话
梦谈多话 2021-01-06 04:48

I have an app that overrides the onTouchEvent(MotionEvent ev) of the MainActivity to determine Two-Finger-Swipe and Pich-Open

3条回答
  •  盖世英雄少女心
    2021-01-06 05:33

    I was having some issues recognizing gestures for items within the navigation drawer itself and came across requestDisallowInterceptTouchEvent. What I found was that I was getting the MotionEvent.ACTION_DOWN, but nothing after that because the NavigationDrawer was intercepting the touches. The key would be to call requestDisallowInterceptTouchEvent(true) on the down event in your touch handler in the activity so that you can handle the touch without it being intercepted.

    This presentation was also extremely useful when trying to figure out the touch system in Android.

提交回复
热议问题