我有一个布局由CoordinatorLayout
母体的用含有ViewPager
,其中包含一个NestedScrollView
一个RecyclerView
:CoordinatorLayout:如何防止滚动事件到达RecyclerView?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.snap.MainActivity"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:id="@+id/scroll_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="vertical"
android:layout_gravity="top"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent">
</LinearLayout>
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/id_viewpager_photosvideos_albums"
android:layout_width="match_parent"
android:layout_height="1000dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout1">
<android.support.design.widget.TabLayout
android:id="@+id/id_tab_photosvideos_albums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.TabLayout>
</android.support.v4.view.ViewPager>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
欲实现如下:
欲拦截(防止)的从达到RecyclerView
滚动事件直到达到某个阈值条件。其中,RecyclerView
将开始正常拦截滚动事件。
我该如何做到这一点?
注:我试图寻找到Behavior.onNestedScroll()
,但似乎并没有这样的伎俩。
嗯,这是一般的。有没有过滤滚动事件的解决方案? –
好吧,我知道,它可能通过这个,但我想节省时间,如果有一个内置/较少涉及的方法可用,我怀疑可能有一个与CoordinatorLayout的所有流行 –
我想我只知道这种方法,你能告诉我确切的条件或要求你想拦截触摸recyclerview我会尝试通过我的方法并排。 –