Skip to content

Android library helps you to draw divider between items in RecyclerView

Notifications You must be signed in to change notification settings

c-b-h/ItemDecorations

 
 

Repository files navigation

Divider(ItemDecoration) for RecyclerView

Download

能够帮助实现RecyclerView分割线效果的ItemDecoration
支持RecyclerView线性,网格,瀑布流布局

Android library helps you to draw divider(ItemDecoration) between items in RecyclerView.

Support

  • LinearLayoutManager
    • Vertical
    • Horizontal
  • GridLayoutManager
    • Vertical
    • Horizontal
  • StaggeredGridLayoutManager

Image

 

Gradle

Add the dependency

dependencies {
    compile 'com.aches.plugins:recyclerview-divider:1.0.1'

    // 3.0
    // implementation 'com.aches.plugins:recyclerview-divider:1.0.1'
}

How To Use

分割线支持设置Color以及Drawable, 也可以通过实现接口IDividerPainter进行自定义分割线.

Drawable dividerDrawable = getResources().getDrawable(R.drawable.shape_divider_vertical);
int dividerColor = getResources().getColor(R.color.divider);
  
LinearLayoutDivider divider = new LinearLayoutDivider.Builder()
        .setOrientation(LinearLayoutManager.VERTICAL)
        .drawFirstDivider(true)
        .drawLastDivider(true)
        .setStartPadding(0)
        .setEndPadding(0)
// color.
        .setDividerColor(dividerColor)
// drawable.
//      .setDividerDrawable(dividerDrawable)
// 自定义IDividerPainter.
//      .setPainter(new DrawablePainter(dividerDrawable))
//      .setPainter(new ColorIntPainter(dividerColor))
        .setDividerThickness(10)// 设置分割线的厚度.
        .build();
recyclerview.addItemDecoration(divider);
Drawable dividerDrawable = getResources().getDrawable(R.drawable.shape_divider);
int dividerColor = getResources().getColor(R.color.divider);

GridLayoutDivider divider = new GridLayoutDivider.Builder()
        .setOrientation(LinearLayoutManager.VERTICAL)
        .drawTopEdgeDivider(true)
        .drawBottomEdgeDivider(true)
        .drawLREdgesDivider(true)
// color.
        .setDividerColor(dividerColor)
        .setSideDividerColor(dividerColor)
// drawable.
//      .setDividerDrawable(dividerDrawable)
//      .setSideDividerDrawable(sideDividerDrawable)
// 自定义IDividerPainter.
//      .setPainter(new ColorIntProvider(dividerColor))
//      .setSidePainter(new DrawableProvider(dividerDrawable))
        .setDividerThickness(15)
        .setSideDividerThickness(20)
        .build();
recyclerview.addItemDecoration(divider);

License

Copyright (C) 2018 AchesKkk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Android library helps you to draw divider between items in RecyclerView

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%