私は、カードにNestedScrollViewがある左右のスワイプ可能なカードシステム(Tinderなど)を作成しようとしています。目標は、ユーザーが上下にスワイプした場合、NestedScrollViewはスクロールしますが、ユーザーが左右にスワイプした場合、カードはそのスワイプを使用します。Android NestedScrollViewを親に水平スワイプを渡す
<?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>
(私が使用していますカードライブラリがあるhttps://github.com/wenchaojiang/AndroidSwipeableCardStack)私はNestedScrollViewとその余白内のタッチにmargin_topを置く
compile 'com.github.wenchaojiang:AndroidSwipeableCardStack:0.1.5'
は、CardStackが正しくつかむ私の入力と左のカードを移動しますか、 NestedScrollViewは、どこにでもタッチしてドラッグすると、方向に関係なく入力を取得します。
この効果を得るには、どのクラス/ onTouchEventを拡張/オーバーライドする必要がありますか、より簡単なアプローチがありますか?
ありがとうございます!
私も、これを把握しようと考えるとしようとしています... 1)onInterceptTouch親クラスで(記録ステップ多分と派遣?)2)実装NestedChildHelper 2にライブラリを変更する)ItemTouchHelperとRecyclerview ..これまでのかなりタフなもの。 。問題があるのかどうかは分かりませんが、私が試している図書館は、劇的なシャッフルとスワイプスタックです。 https://github.com/Meetic/Shuffleとhttps://github.com/flschweiger/SwipeStack – nAndroid
これらのライブラリの1つを使うことは、彼らが多く行っているrecyclerview b/cよりも好ましい方法です。 – nAndroid
私はonInterceptTouchEvent()があなたが探しているメソッドだと思います。 https://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent(android.view.MotionEvent) –