addHeaderView in RecyclerView
As we all know there is addHeaderView in ListView to add header item. But there is no equivalent to this in RecyclerView. Here i am sharing short demo for addHeaderView in RecyclerView.
add dependency in build.gradle
1 |
compile 'com.android.support:recyclerview-v7:23.1.1' |
add RecyclerView in your main xml
1 2 3 4 5 |
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list_recylclerview" android:layout_width="match_parent" android:layout_height="match_parent" /> |
row_layout.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#E5E5E5" android:padding="20dp"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Android Gig" android:textSize="18dp" /> <TextView android:id="@+id/decription" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/title" android:textSize="14dp" /> </RelativeLayout> |