In the below example code I have described how to add Header in RecyclerView without using any external library. For that, Firstly, I have created a header.xml layout and here I have added a TextView.
Now see programing In MyAdapter class I have declared constant variable for header and recycler view items. In onCreateViewHolder method I have inflated both header.xml and list_item.xml layout. In onBindViewHolder method I have set text header name. After this, I have used getItemViewType method for set header postion .