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.

Fast swipe handled by viewpager, not swipereveallayout

See original GitHub issue

Thanks for your good library!

I am doing doing a viewpager and one of the pages are populated with a list of SwipeRevealLayout items. My problem is that a fast swipe on the SwipeRevealLayout item triggers the viewpager instead. Is there a way to ensure that it is the SwipeRevealLayout item, that is triggered, also for fast swipe?

layout_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

context.xml (RevealLayoutItem)

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_gravity="left"
    android:gravity="left"
    android:layout_margin="10dp"
    android:background="@android:color/black"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <com.chauthai.swipereveallayout.SwipeRevealLayout
        android:id="@+id/swipe_layout"
        android:layout_width="match_parent"
        android:layout_height="82dp"
        app:dragEdge="right"
        app:mode="same_level">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="150dp"

                android:background="#00FF00"
                android:orientation="vertical"
                android:showDividers="middle"
                android:layout_margin="40dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="Details" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginRight="100dp"
                android:background="#ffffff"
                android:orientation="vertical"
                android:showDividers="middle">

                <TextView
                    android:id="@+id/row1_col1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:padding="8dp"
                    android:text="Obligationslån, 5%" />
            </LinearLayout>

        </com.chauthai.swipereveallayout.SwipeRevealLayout>
</LinearLayout>

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
MhtSutharcommented, Sep 12, 2018

In SwipeRevealLayout class, you can set this requestDisallowInterceptTouchEvent to true Mine problem was resolved getParent().requestDisallowInterceptTouchEvent(true);

1reaction
romaombcommented, Oct 24, 2018

The explanation from @MhtSuthar gave me a good direction to solve this. For me, I had to use requestDisallowInterceptTouchEvent inside setOnTouchListener of swipeRevealLayout. For example:

(Kotlin)

swipeRevealLayout.setOnTouchListener { view, _ ->    
    view.parent.requestDisallowInterceptTouchEvent(true)
    false
}

(JAVA)

swipeRevealLayout.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        v.getParent().requestDisallowInterceptTouchEvent(true)
        return false;
    }
});

That solved my problem of changing page when swiping right.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do disable paging by swiping with finger in ViewPager ...
Does not work sometimes. I'm using a ViewPager with a FragmentPagerAdapter and several Fragment . After setting OnTouchListener to pager, if I fling...
Read more >
Create swipe views with tabs using ViewPager
Swipe views allow you to navigate between sibling screens, such as tabs, with a horizontal finger gesture, or swipe.
Read more >
RecyclerView has scrolling issues within a ViewPager
They layout is the parent Fragment that has a ViewPager of Fragments. Here is the layout (Fragment): ... Many times I've tried to...
Read more >
Controlling swipe direction with ViewPager2 - Droidcon
In one of the places where we are using ViewPager in our app, ... Now that we know that RecyclerView handles view rendering, ......
Read more >
Android ViewPager Example Tutorial - DigitalOcean
Android ViewPager. Android ViewPager widget is found in the support library and it allows the user to swipe left or right to see...
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