首页 > 解决方案 > RecyclerView 在滚动时覆盖 ImageView

问题描述

我有一个RecylerView低于ImageView

在此处输入图像描述

我希望在用户向下RecyclerView滚动ImageView列表时滚动。如果他们滚动回顶部,ImageView则应显示。我知道我可以通过将 添加ImageView到项目列表来完成此操作,但我不希望ImageView与列表一起滚动,它应该保持原位并RecylerView覆盖它。

这就是我的布局:

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/episodes_list_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/episode_list_thumbnail"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/episode_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintTop_toBottomOf="@+id/episode_list_progress_text_thumbnail"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            />

</androidx.constraintlayout.widget.ConstraintLayout>

此项目列表正在填充自定义项,RecyclerView.Adapter但我不确定这是否相关。

标签: androidandroid-layoutandroid-recyclerview

解决方案


推荐阅读