-
全包裹:
LinearLayoutManagerDivider divider = new LinearLayoutManagerDivider(color, dividerWidth); // 如果RecyclerView有HeaderView或FooterView(不需要绘制分割线) // 按下面的方法添加进Divider中(不会影响UI,仅用于计算) divider.addHeaderView(headerView); divider.addFooterView(footerView); // rv.addItemDecoration(divider);
-
非全包裹:
LinearLayoutManagerDivider divider = new LinearLayoutManagerDivider(color, dividerWidth, false); // 如果RecyclerView有HeaderView或FooterView(不需要绘制分割线) // 按下面的方法添加进Divider中(不会影响UI,仅用于计算) divider.addHeaderView(headerView); divider.addFooterView(footerView); // rv.addItemDecoration(divider);
-
Full Wrap:
GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, dividerWidth); // 如果你想为横向和竖向的分割线设置不同的size: GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, horizontalDividerHeight, horizontalDividerHeight, true); // 如果RecyclerView有HeaderView或FooterView(不需要绘制分割线) // 按下面的方法添加进Divider中(不会影响UI,仅用于计算) divider.addHeaderView(headerView); divider.addFooterView(footerView); // rv.addItemDecoration(divider);
-
Not Full Wrap:
GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, dividerWidth, false); // 如果你想为横向和竖向的分割线设置不同的size: GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, horizontalDividerHeight, verticalDividerWidth, false); // 如果RecyclerView有HeaderView或FooterView(不需要绘制分割线) // 按下面的方法添加进Divider中(不会影响UI,仅用于计算) divider.addHeaderView(headerView); divider.addFooterView(footerView); // rv.addItemDecoration(divider);
添加以下配置到项目根目录位置的build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
在Module目录下的build.gradle文件内添加依赖:
dependencies {
// 对于android compat版本
implementation 'com.github.zeropercenthappy:ZPHRVItemDecoration:1.0.9'
// 对于androidX版本
implementation 'com.github.zeropercenthappy:ZPHRVItemDecoration:1.1.0'
}
-
1.1.0
迁移至AndroidX。
-
1.0.9
Support different size of horizontal and vertical divider for GridLayoutManager.
-
1.0.8
fix draw way of not full wrap style.
-
1.0.7
Use kotlin to rewrite, rewrite all calculate logic, support to set header view and footer view.
-
1.0.6
Downgrade minSdkVersion to 14
-
1.0.4
Add sources jar
-
1.0.3
Fix build error
-
1.0.2
Support RecycleView set padding now.