RecyclerView是support-v7包中的新组件,是一个强大的滑动组件,与经典的ListView相比,同样拥有item回收复用的功能,这一点从它的名字Recyclerview即回收view也可以看出
RecyclerView是官方在5.0之后新添加的控件,推出用来替代传统的ListView和GridView列表控件。
=================================================================================
1.xml下添加RecyclerView控件
2.添加依赖
implementation ‘androidx.recyclerview:recyclerview:1.1.0’
3.创建item
核心代码:
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout
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=“100dp