Created
May 24, 2020 21:08
-
-
Save cmorigaki/d402403e3443cfefce11b071b9c0006d to your computer and use it in GitHub Desktop.
Margin Item Decoration (Simple)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarginItemDecoration(private val spaceSize: Int) : RecyclerView.ItemDecoration() { | |
override fun getItemOffsets( | |
outRect: Rect, view: View, | |
parent: RecyclerView, | |
state: RecyclerView.State | |
) { | |
with(outRect) { | |
if (parent.getChildAdapterPosition(view) == 0) { | |
top = spaceSize | |
} | |
left = spaceSize | |
right = spaceSize | |
bottom = spaceSize | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment