Adding header view to recyclerview with gridlayout manager

Adding header view to recyclerview with gridlayout manager

Android Adding header view to recyclerview with gridlayout manager:
To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the entire list. 
Take a regular RecyclerView.Adapter class and configure it as follows:



The same approach can be used add a footer in addition to or instead of a header.

Comments :

Post a Comment