【发布时间】:2019-05-29 09:57:29
【问题描述】:
我有一个包含 2 个回收站视图的父级 NestedScrollView。一个水平滚动,另一个垂直滚动。如何检测哪一个被滚动?下面是我的 xml 布局。
我无法从 NestedScrollView 中提取我的 recyclerviews,因为这个嵌套滚动视图正在协调器布局中使用,所以我必须将我的 recyclerviews 保留在 NestedScrollview 中。
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollableContent"
android:paddingTop="24dp"
android:clipToPadding="false">
<TextView
style="@style/GatewayLabel"
android:id="@+id/privateGatewaysLabel"
android:text="@string/private_gateways_label"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/privateGatewaysRecycler"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingEnd="20dp"
android:paddingStart="20dp"
android:clipToPadding="false"
android:overScrollMode="never"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/privateGatewaysLabel" />
<TextView
android:id="@+id/sharedGatewayLabel"
style="@style/GatewayLabel"
android:layout_marginTop="16dp"
android:text="@string/shared_gateways_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/privateGatewaysRecycler" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/sharedGatewaysRecycler"
android:overScrollMode="never"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/sharedGatewayLabel" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
【问题讨论】:
标签: android android-recyclerview android-coordinatorlayout android-nestedscrollview