我有一個佈局由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我會嘗試通過我的方法並排。 –