给RecyclerView添加头和尾的方法很多,这里写两种最简单的方法。
1.控制布局 显隐
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="30dp" android:gravity="center" android:visibility="gone" android:text="这是子标题栏"/> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp"> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:background="@mipmap/ic_launcher" />