0
点赞
收藏
分享

微信扫一扫

Android NestedScrollView包裹RecyclerView高度撑满所有item,kotlin

瑾谋 2023-07-19 阅读 39

Android NestedScrollView包裹RecyclerView高度撑满所有item,kotlin

当用NestedScrollView包裹RecyclerView后,

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" />

</androidx.core.widget.NestedScrollView>

 

然而设置:

recyclerView?.isNestedScrollingEnabled = false

会使得RecyclerView加载完成所有itemCount的数理,撑满整个RecyclerView高度,这深深改变了RecyclerView只加载显示当前屏幕可见区域的特性,此时RecyclerView一次性加载全部item。

 

 

举报

相关推荐

0 条评论