【发布时间】:2020-04-09 06:43:05
【问题描述】:
我正在使用内部有 4 个片段的 Horizontal ViewPager2。每个片段在 RecyclerView 上都有 SwipeRefreshLayout。我面临的问题是,当 RecyclerView 位于顶部位置时,任何项目的 onClick 列表都不起作用。如果我将 RecyclerView 向下滚动一点,则 onClick 可以正常工作。当 RecyclerView 处于顶部位置时,如果 SwipeRefreshLayout 处于刷新状态,则 onClick 工作正常。似乎 SwipeRefreshLayout 在触摸事件中与 ViewPager2 冲突。它适用于简单的 ViewPager。什么可能是实际问题,我们该如何处理?任何想法都会很有意义。
谢谢
xml:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/fragment_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<include
android:id="@+id/headerPanel"
layout="@layout/home_header"
app:viewModel="@{viewModel}" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingStart="@dimen/home_post_side_spacing"
android:paddingEnd="@dimen/home_post_side_spacing"
app:colorScheme="@{@color/fayvo_color}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/headerPanel"
app:onRefreshListener="@{() -> viewModel.manualRefresh()}"
app:refreshing="@{viewModel.isRefreshing}"
android:background="#f0f0f0">
<RelativeLayout
android:id="@+id/rl_rv"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_homePosts"
adapter="@{viewModel.postObservableArrayList}"
addToTop="@{viewModel.addToTop}"
clearList="@{viewModel.clearList}"
showLoader="@{viewModel.isPagingEnabled && viewModel.isLoading}"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<FrameLayout
android:id="@+id/emptyFrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="@{viewModel.showEmptyLayout?View.VISIBLE:View.GONE}" />
<include
android:id="@+id/postUploadProgressLayout"
layout="@layout/item_post_upload_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:viewModel="@{viewModel}" />
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<View
android:id="@+id/tooltipView"
android:layout_width="1dp"
android:layout_height=".1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
-
你能添加你的xml吗
标签: android android-recyclerview android-viewpager swiperefreshlayout android-viewpager2