Closed Just-D-A closed 3 years ago
fun DividerItemDecoration.addInset(context: Context, insetResId: Int): DividerItemDecoration { val attrs = intArrayOf(android.R.attr.listDivider) val attr = context.obtainStyledAttributes(attrs) val divider = attr.getDrawable(0) val inset = context.resources.getDimensionPixelSize(insetResId) val insetDivider = InsetDrawable(divider, inset, 0, inset, 0) attr.recycle() setDrawable(insetDivider) return this }
fun DividerItemDecoration.addInset(context: Context, insetResId: Int): DividerItemDecoration { val attrs = intArrayOf(android.R.attr.listDivider) val attr = context.obtainStyledAttributes(attrs) val divider = attr.getDrawable(0) val inset = context.resources.getDimensionPixelSize(insetResId) val insetDivider = InsetDrawable(divider, inset, 0, inset, 0) attr.recycle() setDrawable(insetDivider) return this }