question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swipe layout not working inside viewpager.

See original GitHub issue

I implemented swipe layout like the example and it worked perfectly, but when i moved the swipeRecyclerView inside a child fragment that is inside a ViewPager, swipe doesn’t intercept touch event and instead, viewpager swipes the fragments… What can i do to fix this?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Rainer-Langcommented, Aug 13, 2015

I have read many blogs and sites with tipps… I only found one acceptable solution for me.

You have to make your own ViewPager class:

public class OwnViewPager extends ViewPager {

    private boolean enabled;

    public OwnViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.enabled = true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return this.enabled && super.onTouchEvent(event);

    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return this.enabled && super.onInterceptTouchEvent(event);

    }

    public void setPagingEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}

Use setPagingEnabled(boolean) to en/disable swipe for the ViewPager. Also a solution is to make this accessable via xml.

0reactions
Rainer-Langcommented, Aug 13, 2015

I have a solution. Will post in an hour

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swipe not working inside a viewpager · Issue #482 - GitHub
I have two fragments inside a view pager. Last fragment has a recycler view where I am trying to implement Swipe to Dismiss...
Read more >
ScrollView inside ViewPager: swipe not working
In this case, you can do something that tests if the swipe is up/down, and then keep the touch, otherwise if the swipe...
Read more >
ViewPager with FragmentPagerAdapter - CodePath Cliffnotes
Layout that allows the user to swipe left and right through "pages" of content which are usually different fragments. This is a common...
Read more >
RecyclerView has scrolling issues within a ViewPager
1) When using an AppBarLayout(with tabs) along side a ViewPager that contains a RecyclerView, if you slowly swipe up or down the RecyclerView...
Read more >
Create swipe views with tabs using ViewPager2
You can create swipe views using AndroidX's ViewPager2 widget. To use ViewPager2 and tabs, you need to add a dependency on ViewPager2 and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found