recycler-view-divider / com.fondesa.recyclerviewdivider / DividerBuilder

DividerBuilder

class DividerBuilder

Builds a divider for a LinearLayoutManager or its subclasses (e.g. GridLayoutManager). The following properties of a divider can be configured:

Parameters

context - the Context used to build the divider.

Functions

asSpace

fun asSpace(): DividerBuilder

Sets the divider as a simple space, so the divider leaves the space between two cells but it is not rendered. Since the rendering is totally skipped in this case, it's better than using a transparent color.

build

fun build(): BaseDividerItemDecoration

Creates the RecyclerView.ItemDecoration using the configuration specified in this builder. If this builder doesn't specify the configuration of some divider's properties, those properties will be picked from the theme or their default will be used.

color

fun color(color: Int): DividerBuilder

Sets the divider's drawable as a solid color.

colorRes

fun colorRes(colorRes: Int): DividerBuilder

Sets the divider's drawable as a solid color.

drawable

fun drawable(drawable: Drawable): DividerBuilder

Sets the divider's drawable.

drawableProvider

fun drawableProvider(provider: DrawableProvider): DividerBuilder

Customizes the drawable of each divider in the grid. IMPORTANT: The default DividerOffsetProvider can't ensure the same size of the items in a grid when this method is called. If you want a different behavior, you can specify a custom DividerOffsetProvider with offsetProvider.

drawableRes

fun drawableRes(drawableRes: Int): DividerBuilder

Sets the divider's drawable.

insetEnd

fun insetEnd(end: Int): DividerBuilder

Sets the divider's end inset. The inset will behave as a margin/padding of the divider's drawable. The end inset in an horizontal divider is the right inset in left-to-right and the left inset in right-to-left. The end inset in a vertical divider is the bottom inset in top-to-bottom and the top inset in bottom-to-top.

insetProvider

fun insetProvider(provider: InsetProvider): DividerBuilder

Customizes the insets of each divider in the grid.

insets

fun insets(start: Int, end: Int): DividerBuilder

Sets the divider's insets. The inset will behave as a margin/padding of the divider's drawable. The start inset in an horizontal divider is the left inset in left-to-right and the right inset in right-to-left. The start inset in a vertical divider is the top inset in top-to-bottom and the bottom inset in bottom-to-top. The end inset in an horizontal divider is the right inset in left-to-right and the left inset in right-to-left. The end inset in a vertical divider is the bottom inset in top-to-bottom and the top inset in bottom-to-top.

insetStart

fun insetStart(start: Int): DividerBuilder

Sets the divider's start inset. The inset will behave as a margin/padding of the divider's drawable. The start inset in an horizontal divider is the left inset in left-to-right and the right inset in right-to-left. The start inset in a vertical divider is the top inset in top-to-bottom and the bottom inset in bottom-to-top.

offsetProvider

fun offsetProvider(provider: DividerOffsetProvider): DividerBuilder

Customizes the offset of each divider in the grid. This method is useful to balance the size of the items in a grid with multiple columns/rows.

showFirstDivider

fun showFirstDivider(): DividerBuilder

Shows the first divider of the list/grid. The first divider is the one before the items in the first line.

showLastDivider

fun showLastDivider(): DividerBuilder

Shows the last divider of the list/grid. The last divider is the one after the items in the last line.

showSideDividers

fun showSideDividers(): DividerBuilder

Shows the side dividers of the list/grid. The side dividers are the ones before the first column and after the last column.

size

fun size(size: Int, sizeUnit: Int = TypedValue.COMPLEX_UNIT_PX): DividerBuilder

Sets the divider's size. The size of an horizontal divider is its height. The size of a vertical divider is its width.

sizeProvider

fun sizeProvider(provider: SizeProvider): DividerBuilder

Customizes the size of each divider in the grid. IMPORTANT: The default DividerOffsetProvider can't ensure the same size of the items in a grid when this method is called. If you want a different behavior, you can specify a custom DividerOffsetProvider with offsetProvider.

tint

fun tint(color: Int): DividerBuilder

Sets the tint color of the divider's drawable.

tintProvider

fun tintProvider(provider: TintProvider): DividerBuilder

Customizes the tint color of each divider's drawable in the grid.

visibilityProvider

fun visibilityProvider(provider: VisibilityProvider): DividerBuilder

Customizes the visibility of each divider in the grid. IMPORTANT: The default DividerOffsetProvider can't ensure the same size of the items in a grid when this method is called. If you want a different behavior, you can specify a custom DividerOffsetProvider with offsetProvider.