Skip to content

Instantly share code, notes, and snippets.

@mohamed-khaled-hsn
Created November 1, 2019 14:13
Show Gist options
  • Save mohamed-khaled-hsn/cc1abe362433be015efda82ff612f848 to your computer and use it in GitHub Desktop.
Save mohamed-khaled-hsn/cc1abe362433be015efda82ff612f848 to your computer and use it in GitHub Desktop.
MarginItemDecoration
class MarginItemDecoration(
private val left: Int? = null,
private val top: Int? = null,
private val right: Int? = null,
private val bottom: Int? = null
) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
) {
left?.let { outRect.left = it }
top?.let { outRect.top = it }
right?.let { outRect.right = it }
bottom?.let { outRect.bottom = it }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment