========================================================================
在绘制吸顶效果之前,需要先实现一个RecyclerView功能列表
新建一个item 的Layout 文件
<?xml version="1.0" encoding="utf-8"?><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”>
<TextView
android:id=“@+id/user_name”
android:text=“姓名”
android:gravity=“center”
android:layout_width=“match_parent”
android:layout_height=“44dp”
android:textSize=“20sp”
tools:ignore=“MissingConstraints” />
在 RecyclerView 中引用item
<?xml version="1.0" encoding="utf-8"?><LinearLayout 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/main_rv”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:listitem=“@layout/item”
/>
public class Star {
String userName;
String groupName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Star(String userName, String groupName) {
this.userName = userName;
this.groupName &