-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecyclerViewExtensions.kt
30 lines (27 loc) · 1.34 KB
/
RecyclerViewExtensions.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.tazkiyatech.utils.views
import androidx.annotation.ColorInt
import androidx.recyclerview.widget.RecyclerView
/**
* Sets the colored divider that will be drawn between each item in the [RecyclerView].
*
* Note that this method calls into the [RecyclerView.addItemDecoration] method internally.
* This call will likely conflict with any other calls to [RecyclerView.addItemDecoration] that you make on the [RecyclerView].
*/
fun RecyclerView.setColoredDivider(@ColorInt dividerColor: Int,
dividerHeightPixels: Int,
dividerMarginLeftPixels: Int = 0,
dividerMarginRightPixels: Int = 0) {
val itemDecoration = RecyclerViewColoredDividerItemDecoration(
dividerColor, dividerHeightPixels, dividerMarginLeftPixels, dividerMarginRightPixels
)
addItemDecoration(itemDecoration)
}
/**
* Sets the vertical gap that will be drawn between each item in the [RecyclerView].
*
* Note that this method calls into the [RecyclerView.addItemDecoration] method internally.
* This call will likely conflict with any other calls to [RecyclerView.addItemDecoration] that you make on the [RecyclerView].
*/
fun RecyclerView.setVerticalGap(verticalGapInPixels: Int) {
addItemDecoration(RecyclerViewVerticalGapItemDecoration(verticalGapInPixels))
}