gpt4 book ai didi

Android:RecyclerView 滚动问题

转载 作者:行者123 更新时间:2023-11-30 01:49:10 28 4
gpt4 key购买 nike

我有一个 fragment ,其中包括一个 Textview 和一个 RecyclerView(列表)

我的问题是当滚动 RecyclerView 时,它上面的 TextView 停留在顶部并且不会滚动。

如何使 textview 像 ScrollView 一样非粘性和可滚动?

我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.easyuni.courserecommender.ResultsCareerTabFragment">

<TextView
android:id="@+id/tv_results_rec_careers_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="24dp"
android:text="@string/results_rec_careers_title"
android:textSize="24sp"
android:textStyle="bold" />

<android.support.v7.widget.RecyclerView
android:id="@+id/rv_careers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_results_rec_careers_title"
android:layout_gravity="center"
android:layout_marginTop="20dp"></android.support.v7.widget.RecyclerView>

</RelativeLayout>

截图:

正常外观: enter image description here

在 RecyclerView 中向下滚动时:enter image description here

谢谢。

最佳答案

您需要将 TextView 添加为一个项目,为您的回收站 View 提供适配器。您可以使用以下代码来区分要在 recyclerview 中显示的 View :

public int getItemViewType (int position)

请看看这个线程:

How to create RecyclerView with multiple view type?

关于Android:RecyclerView 滚动问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33316872/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com