Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ViewPagerTabListViewFragment] The view pager changes the sliding bar selected location with onTouch event. #117

Closed
AabidMulani opened this issue May 1, 2015 · 4 comments

Comments

@AabidMulani
Copy link

I am facing the following issue:

  • Using ActionBar-Tab-ViewPager activity and ViewPagerTabListViewFragment
  • The first child fragment works perfect
  • But when you swipe to the second fragment and touch any where on the fragment the Sliding Tab flickers and most of the time shifts to the next child.
  • Swiping reverse works fine, but while swiping forward, many times it catches the onTouch event instead of the swipe event and hence the flickring /next child selection.

Check this link for the code: http://stackoverflow.com/questions/29991358/android-observablescrollview-unexpected-touch-changes-the-child-fragment-while

And here is the video of the exact issue: https://youtu.be/0katNDIWcmg

@ksoichiro
Copy link
Owner

Hi, thank you for your feedback.
I've confirmed the issue and answered in Stack Overflow just now,
I'll also write it here, just for tracking the issue.

It seems it's a problem inside the ObservableListView, sorry.
To intercept touch events, ObservableListView is designed to call its parent's onInterceptTouchEvent() and the parent -- in this case, the parent is ViewPager -- accidentally handles the touch event, which causes this behavior.

Anyway, I found a workaround for this.
Could you try this in your app?

  1. Add an ID like to the root ViewGroup
    in your MainActivity-Layout.xml, like android:id="@+id/root":

    <FrameLayout
            android:id="@+id/root"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <!--
            Padding for ViewPager must be set outside the ViewPager itself
            because with padding, EdgeEffect of ViewPager become strange.
            -->
  2. Then set this FrameLayout as TouchInterceptionViewGroup
    to the ObservableListView in ViewPagerTabListViewFragment.java.
    Maybe around listView.setScrollViewCallbacks() is good.

    listView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));
    listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);

With this workaround, you can avoid the ViewPager handles the ACTION_MOVE event.

@michaelbarlow7
Copy link

Thanks for posting the workaround, this same issue occurs with ObservableScrollView as well.

@ksoichiro
Copy link
Owner

@AabidMulani @michaelbarlow7
Thanks for checking! I added this workaround for both examples.

@radikan
Copy link

radikan commented May 22, 2015

Thank you for your workaround! Everything works like a charm now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants