Skip to content

ItemDecoration for RecycleView with LinearLayoutManager or vertical GridLayoutmanager

License

Notifications You must be signed in to change notification settings

zeropercenthappy/ZPHRVItemDecoration

Repository files navigation

ZPHRVItemDecoration 简体中文

Divider

LinearLayoutManager

Usage

  • Full Wrap:

    LinearLayoutManagerDivider divider = new LinearLayoutManagerDivider(color, dividerWidth);
    // if you have header view or footer view.
    // it will not influence layout, only use for calculate.
    divider.addHeaderView(headerView);
    divider.addFooterView(footerView);
    //
    rv.addItemDecoration(divider);

    LinearLayoutManagerFullwrap

  • Not Full Wrap:

    LinearLayoutManagerDivider divider = new LinearLayoutManagerDivider(color, dividerWidth, false);
    // if you have header view or footer view.
    // it will not influence layout, only use for calculate.
    divider.addHeaderView(headerView);
    divider.addFooterView(footerView);
    //
    rv.addItemDecoration(divider);

    LinearLayoutManager

GridLayoutManager

Usage (Current version only support Vertical GridLayoutManager)

  • Full Wrap:

    GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, dividerWidth, true);
    // if you want to set a different size of divider:
    GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, horizontalDividerHeight, horizontalDividerHeight, true);
    // if you have header view or footer view.
    // it will not influence layout, only use for calculate.
    divider.addHeaderView(headerView);
    divider.addFooterView(footerView);
    //
    rv.addItemDecoration(divider);

    GridLayoutManager

  • Not Full Wrap:

    GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, dividerWidth, false);
    // if you want to set a different size of divider:
    GridLayoutManagerDivider divider = new GridLayoutManagerDivider(color, horizontalDividerHeight, verticalDividerWidth, false);
    // if you have header view or footer view.
    // it will not influence layout, only use for calculate.
    divider.addHeaderView(headerView);
    divider.addFooterView(footerView);
    //
    rv.addItemDecoration(divider);

    GridLayoutManager

Download

Step 1.

Add it in your root build.gradle at the end of repositories:

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

Step 2.

Add the dependency in your module's build.gradle:

dependencies {
    // For android compat version
    implementation 'com.github.zeropercenthappy:ZPHRVItemDecoration:1.0.9'
    // For androidX version
    implementation 'com.github.zeropercenthappy:ZPHRVItemDecoration:1.1.0'
}

Change log

  • 1.1.0

    Migrate to 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.

About

ItemDecoration for RecycleView with LinearLayoutManager or vertical GridLayoutmanager

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published