Skip to content

Latest commit

 

History

History
134 lines (92 loc) · 3.61 KB

README_CN.md

File metadata and controls

134 lines (92 loc) · 3.61 KB

ZPHRVItemDecoration

分割线

LinearLayoutManager

用法

  • 全包裹:

    LinearLayoutManagerDivider divider = new LinearLayoutManagerDivider(color, dividerWidth);
    // 如果RecyclerView有HeaderView或FooterView(不需要绘制分割线)
    // 按下面的方法添加进Divider中(不会影响UI,仅用于计算)
    divider.addHeaderView(headerView);
    divider.addFooterView(footerView);
    //
    rv.addItemDecoration(divider);

    LinearLayoutManagerFullwrap

  • 非全包裹:

    LinearLayoutManagerDivider divider = new LinearLayoutManagerDivider(color, dividerWidth, false);
    // 如果RecyclerView有HeaderView或FooterView(不需要绘制分割线)
    // 按下面的方法添加进Divider中(不会影响UI,仅用于计算)
    divider.addHeaderView(headerView);
    divider.addFooterView(footerView);
    //
    rv.addItemDecoration(divider);

    LinearLayoutManager

GridLayoutManager

用法 (当前仅支持Vertical方向的GridLayoutManager绘制分割线)

  • 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);

    GridLayoutManager

  • 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);

    GridLayoutManager

下载

步骤 1.

添加以下配置到项目根目录位置的build.gradle:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

步骤 2.

在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.