Computer scienceMobileAndroidUser InterfaceGraphics

ItemDecoration

Theory

Make offsets

Report a typo

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.

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