DefaultDecoration

class DefaultDecoration(context: Context) : RecyclerView.ItemDecoration

最强大的分割线工具

  1. 分隔图片

  2. 分隔颜色

  3. 分隔间距

  4. 回调函数判断间隔

  5. 首尾是否显示分隔线, 可以展 示表格效果

  6. 类型池来指定是否显示分割线

  7. 支持全部的LayoutManager, 竖向/横向/网格分割线

  8. 优于其他框架, 完美支持均布网格分隔物

  9. 支持分组条目的分割线

Constructors

DefaultDecoration
Link copied to clipboard
fun DefaultDecoration(context: Context)

Types

Edge
Link copied to clipboard
data class Edge(left: Boolean, top: Boolean, right: Boolean, bottom: Boolean)
列表条目是否靠近边缘的结算结果

Functions

addType
Link copied to clipboard
fun addType(@LayoutRes() vararg typeArray: Int)
添加类型后只允许该类型的条目显示分割线 从未添加类型则默认为允许全部条目显示分割线
getItemOffsets
Link copied to clipboard
open override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State)
onDraw
Link copied to clipboard
open override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State)
onEnabled
Link copied to clipboard
fun onEnabled(block: BindingAdapter.BindingViewHolder.() -> Boolean)
根据回调函数来决定是否启用分割线
setBackground
Link copied to clipboard
fun setBackground(@ColorInt() color: Int)
分割线背景色 分割线有时候会存在间距(例如配置setMargin)或属于虚线, 这个时候暴露出来的是RecyclerView的背景色, 所以我们可以设置一个背景色来调整 可以设置背景色解决不统一的问题, 默认为透明Color.TRANSPARENT
fun setBackground(colorString: String)
分割线背景色 分割线有时候会存在间距(例如配置setMargin)或属于虚线, 这个时候暴露出来的是RecyclerView的背景色, 所以我们可以设置一个背景色来调整 可以设置背景色解决不统一的问题, 默认为透明Color.TRANSPARENT
setBackgroundRes
Link copied to clipboard
fun setBackgroundRes(@ColorRes() color: Int)
分割线背景色 分割线有时候会存在间距(例如配置setMargin)或属于虚线, 这个时候暴露出来的是RecyclerView的背景色, 所以我们可以设置一个背景色来调整 可以设置背景色解决不统一的问题, 默认为透明Color.TRANSPARENT
setColor
Link copied to clipboard
fun setColor(@ColorInt() color: Int)
设置分割线颜色, 如果不设置分割线宽度setDivider则分割线宽度默认为1px 所谓分割线宽度指的是分割线的粗细, 而非水平宽度
fun setColor(color: String)
设置分割线颜色, 如果不设置分割线宽度setDivider则分割线宽度默认为1px 所谓分割线宽度指的是分割线的粗细, 而非水平宽度
setColorRes
Link copied to clipboard
fun setColorRes(@ColorRes() color: Int)
设置分割线颜色, 如果不设置分割线宽度setDivider则分割线宽度默认为1px 所谓分割线宽度指的是分割线的粗细, 而非水平宽度
setDivider
Link copied to clipboard
fun setDivider(width: Int = 1, dp: Boolean = false)
设置分割线宽度 如果使用setDrawable则无效
setDrawable
Link copied to clipboard
fun setDrawable(drawable: Drawable)
将图片作为分割线, 图片宽高即分割线宽高
fun setDrawable(@DrawableRes() drawableRes: Int)
将图片作为分割线, 图片宽高即分割线宽高
setMargin
Link copied to clipboard
fun setMargin(start: Int = 0, end: Int = 0, dp: Boolean = true)
设置分隔左右或上下间距, 依据分割线为垂直或者水平决定具体方向间距

Properties

endVisible
Link copied to clipboard
var endVisible: Boolean = false
最后一个条目是否显示分割线, 当处于DividerOrientation.GRID 时垂直方向顶端和末端是否显示分割线
expandVisible
Link copied to clipboard
var expandVisible: Boolean = false
展开分组条目后该条目是否显示分割线
includeVisible
Link copied to clipboard
var includeVisible: Boolean
orientation
Link copied to clipboard
var orientation: DividerOrientation
分割线的方向, 仅支持GridLayoutManager, 其他LayoutManager都是根据其方向自动适应
startVisible
Link copied to clipboard
var startVisible: Boolean = false
第一个条目之前是否显示分割线, 当处于DividerOrientation.GRID 时水平方向顶端和末端是否显示分割线
typePool
Link copied to clipboard
var typePool: MutableList<Int>? = null
集合内包含的类型才显示分割线