Complete the missing sections so that the decoration applies an offset on the left and right of each item, and at the bottom of every even item.
ItemDecoration
Make offsets
Report a typo
Fill in the gaps with the relevant elements
class CustomOffsetItemDecoration(private val spacingInDp: Int): RecyclerView.ItemDecoration() {
override fun (outRect: , view: View, parent: RecyclerView, state: RecyclerView.State) {
outRect.left = spacingInDp
= spacingInDp
val position = parent.getChildAdapterPosition(view) + 1
if ( % 2 == 0) = spacingInDp
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.