I'm trying to make a left-right swipeable card system (like Tinder), where the card has a NestedScrollView on it. The goal would be that if the user swiped up and down only, the NestedScrollView would scroll, but if the user swiped left or right, the Card would use that swipe.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="4dp"
card_view:cardUseCompatPadding="true">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="4dp">
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v7.widget.CardView>
(The card library I am using is https://github.com/wenchaojiang/AndroidSwipeableCardStack )
compile 'com.github.wenchaojiang:AndroidSwipeableCardStack:0.1.5'
When I put a margin_top on the NestedScrollView and touch within that margin, the CardStack correctly grabs my input and the card moves left or right, but the NestedScrollView grabs my input regardless of direction if I touch and drag anywhere else.
Which class/onTouchEvent should I be extending/overriding to have this effect, or might there be a simpler approach?
Thanks!