Open iad24 opened 6 years ago
I usually use this decorator to put space between items in a recyclerview:
class ItemVerticalSpaceDecoration(private val space: Int, private val includeTopBottom: Boolean = true) : RecyclerView.ItemDecoration() { override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { outRect.bottom = space if (parent.getChildAdapterPosition(view) == 0 && includeTopBottom) { // if first item outRect.top = space } else if (parent.getChildAdapterPosition(view) == parent.adapter.itemCount - 1 && !includeTopBottom) { // if last item outRect.bottom = 0 } } }
But when I apply here, the section headers will also get the spacing. How to apply only to the item views?
I usually use this decorator to put space between items in a recyclerview:
But when I apply here, the section headers will also get the spacing. How to apply only to the item views?