我正在尝试制作一个左右可刷卡系统(如Tinder),卡上有一个NestedScrollView.目标是如果用户仅向上和向下滑动,NestedScrollView将滚动,但如果用户向左或向右滑动,则卡将使用该滑动.

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:id="@+id/nested_scroll_view"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:padding="4dp">

android:id="@+id/text_view"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

android:id="@+id/recycler"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

compile 'com.github.wenchaojiang:AndroidSwipeableCardStack:0.1.5'

当我在NestedScrollView上放置margin_top并在该边距内触摸时,CardStack正确地抓取我的输入并且卡片向左或向右移动,但是如果我触摸并拖动其他任何地方,NestedScrollView会抓住我的输入而不管方向.

我应该扩展/覆盖哪个类/ onTouchEvent以产生这种效果,或者可能有更简单的方法?

谢谢!

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐