[英]How do I scroll the screen with the RecyclerView inside with RecyclerView load items step by step?
I have gallery page in my project.我的项目中有画廊页面。 There are different view types in this page like RecyclerView - TextView - ImageView.
此页面中有不同的视图类型,例如 RecyclerView - TextView - ImageView。 If I set height "wrap_content" of RecyclerView, my RecyclerView loads all items.
如果我设置 RecyclerView 的高度“wrap_content”,我的 RecyclerView 会加载所有项目。 That's freeze to my view, because of some galleries has too many items.
我的看法是冻结,因为有些画廊有太多的项目。 I want to load items step by step.
我想逐步加载项目。 But If I set height "match_constraint" of RecyclerView, my gallery page has 2 scroll (One of them is ScrollView, one of them is RecyclerView).
但是如果我设置 RecyclerView 的高度“match_constraint”,我的画廊页面有 2 个滚动(其中一个是 ScrollView,其中一个是 RecyclerView)。 So all view couldn't scroll with together.
所以所有的视图都不能一起滚动。 How do I scroll the screen with the RecyclerView inside with RecyclerView load items step by step?
如何使用 RecyclerView 逐步加载带有 RecyclerView 的屏幕滚动屏幕?
Actually my XML is too long so I didn't add some views in following code.实际上我的XML太长了所以我没有在下面的代码中添加一些视图。
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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:id="@+id/detail_fragment_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:clipChildren="false"
android:clipToPadding="false"
android:fillViewport="true"
android:fitsSystemWindows="false"
android:focusable="true"
tools:context=".DetailActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/detail_fragment_constraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:focusable="true"
android:scrollbars="none">
<TextView
android:id="@+id/feed_detail_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="12dp"
android:paddingLeft="8dp"
android:paddingTop="2dp"
android:paddingRight="8dp"
android:paddingBottom="2dp"
android:textColor="@android:color/black"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent” />
<TextView
android:id="@+id/feed_detail_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintBottom_toBottomOf="@+id/feed_detail_category"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/feed_detail_category" />
<TextView
android:id="@+id/feed_detail_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:paddingLeft="8dp"
android:paddingTop="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/feed_detail_category" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/comment_recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/feed_detail_title” />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.