0

I want to implement a swipe from bottom gesture like windows 8 tablet in android.But I can't catch any touch begin from android navigation bar.

Here is my code in MainActivity.java:

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    Log.d("touch",ev.toString());
    return super.dispatchTouchEvent(ev);
}

Swipe from left or right works fine.But nothing happends when I swipe from navigation bar or from bottom edge in non-navigation bar devices

I tested this on an Android 4.4.4 Tablet and Genymotion.

Vlad
  • 3,346
  • 2
  • 27
  • 39
xcodebuild
  • 1,121
  • 9
  • 17
  • _I swipe from bottom begin from android navigation bar_ Can you explain this? I could not understand how will you start swipe from bottom and `navigation drawer` – Kushal Apr 28 '15 at 11:12
  • @Kushal I means `virtual button bar`,maybe I get a wrong name?Not `navigation drawer` at all. – xcodebuild Apr 28 '15 at 11:15

1 Answers1

2

First things first: Android: Difference between onInterceptTouchEvent and dispatchTouchEvent?. As stated by the best answer, dispatchTouchEvent is actually defined on Activity, View and ViewGroup. Think of it as a controller which decides how to route the touch events. With that in mind, we know that every touch event that starts from the navigation bar (i.e. when you touch your finger on the navigation bar, hold it and swipe up) is not going to be intercepted by the method dispatchTouchEvent.

If that was not the answer you are looking for, then i imagine that you're looking for a way to implement a menu that shows up when you swipe from the bottom-up . Look, this library should help you if this is what you want.

Edit: i found one more example that covers the entire swipe gestures subject that may help you. Follow this link.

Community
  • 1
  • 1
VulfCompressor
  • 1,390
  • 1
  • 11
  • 26