Skip to content

RecyclerViewLinearItemDecoration

arjinmc edited this page Oct 23, 2019 · 1 revision

It's a child class extends RecyclerView.ItemDecoration. No need to tell it,it will auto find the RecyclerView LinearLayoutManager when it draws. Use RecyclerViewLinearItemDecoration.Builder(Context).create() to new a ItemDecoration.

继承RecyclerView.ItemDecoration的子类。不需要告诉它RecyclerView的布局方向。使用RecyclerViewLinearItemDecoration.Builder(Context).create()的方式创建新的分割线。

Attribute 属性

drawable

Use a bitmap or ninepatch image as a ItemDecoration.
使用bitmap或者.9图片作为分割线

  • drawableID(R.drawable.diver)

color

Change the Color of the ItemDecoration. Use one of these method blow:
修改分割线的颜色,可以使用下面的方法中其中一种:

  • color(int color)
  • color(String colorStr)

thickness

the thickness of the ItemDecoration.
分割线的厚度

  • thickness(int thickness)

dash

If you want to use dash line to make a ItemDecoration, set these both attributes
如果你想要一根虚线作为分割线,需要设置以下属性

  1. dashWidth(int dashWidth) 分割的宽度
  2. dashGap(int dashGap) 分割的间隔

padding

  • paddingStart(int padding) -- Set paddingStart 设置开始的间距(头)
  • paddingEnd(int padding) -- Set paddingEnd 设置结束的间距(尾)

first / last line

  • firstLineVisible(boolean visible) -- Set if the top of the first item to show a ItemDecoration 设置是否在第一个item上面/前面显示分割线
  • lastLineVisible(boolean visible) -- Set if the bottom of the last item to show a ItemDecoration 设置是否在最后一个item下面/后面显示分割线

ignoreType

  • ignoreTypes(int[]) -- Set the viewTypes of RecyclerView which won't draw a ItemDecoration 设置要忽略不显示分割线的RecyclerView的对应的viewType类型
Clone this wiki locally