frankelot
frankelot

Reputation: 14439

Android touch event propagation

It's my understanding that Android event propagation goes from parent to child, that is to say, it starts with the outermost element and inwards from there. My question is, why is it that when I try to scroll vertically a listview that is inside a viewpager that is wrapped on a scrollview, the listview moves, and not the viewpager. Okay, let me rephrase that: I'm trying to create a menu that appears when the user pulls down the view pager, let me make that even clearer:

Scrollview My custom Menu ViewPager (with three fragments, all of them have a lisview) ListView

I understand that what I'm trying to do is a bit odd, but bear with me just for this time. :)

What can I do to "disable" momentarily the list views scrolling.

Thanks

Upvotes: 0

Views: 750

Answers (1)

The Original Android
The Original Android

Reputation: 6215

It seems you have to override the scrolling event. A good webpage is Disable scrolling in Android ListView . Mainly look at dispatchTouchEvent. Snippet of it:

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    final int actionMasked = ev.getActionMasked() & MotionEvent.ACTION_MASK;
    if (actionMasked == MotionEvent.ACTION_MOVE) {
        // Ignore move events
        return true;
    }

Personally I wish it is simpler than this like disabling scroll method.

Upvotes: 3

Related Questions