Skip to content
Super ItemDecoration for RecyclerView
Kotlin Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
library
sample
.gitignore
.travis.yml
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

SuperDecoration

Download Build Status 快速设置RecyclerViewitem间间距, 配合此篇文章食用,味道更佳戳我

特性

  1. 支持LinearLayoutManager,GridLayoutManager
  2. 支持单行或单列情况
  3. 支持reverseLayout==true情况
  4. 支持GridLayoutManager设置了SpanSizeLookup情况
  5. 灵活设置各种间距

sample截图

LinearLayoutManager normal GridLayoutManager GridLayoutManager with Span and reverseLayout

使用实例

  1. 引用库
  // 1.添加jcenter仓库
    allprojects {
        repositories {
           jcenter()
        }
    }
    // 2.添加项目依赖(last-version替换为最新版本号)
    dependencies {
        implementation "cc.wecando:SuperDecoration:${last-version}"
    }
  1. 使用
        mRvContent.addItemDecoration(
            SuperOffsetDecoration.Builder(layoutManager, this)
                .setMainAxisEdgeSpace(12F) // 设置与orientation同方向,RecyclerView内间距,orientation为vertical时, 表示 paddingTop,paddingBottom
                .setCrossAxisEdgeSpace(10F)// 设置与orientation垂直方向,RecyclerView内间距,orientation为vertical时, 表示 paddingLeft,paddingRight
                .setMainAxisSpace(8F)// 设置与orientation同方向,ItemView的间距
                .setCrossAxisSpace(4F)// 设置与orientation垂直方向,ItemView的间距, LinearLayoutManager无效
                .build()
        )

主要Api

名称 说明
setMainAxisEdgeSpace 设置与orientation同方向,RecyclerView内间距
setCrossAxisEdgeSpace 设置与orientation垂直方向,RecyclerView内间距
setMainAxisSpace 设置与orientation同方向,ItemView的间距
setCrossAxisSpace 设置与orientation垂直方向,ItemView的间距, LinearLayoutManager无效
setShowDividers 设置显示分割线模式类似于LinearLayout#setShowDividers方法,SHOW_DIVIDER_NONE = 0,SHOW_DIVIDER_BEGINNING = 1,SHOW_DIVIDER_MIDDLE = 2,SHOW_DIVIDER_END = 4
setPaddingLeft 设置分割线paddingLeft
setPaddingRight 设置分割线paddingRight
setDividerColor 设置分割线前景颜色
setBackgroundColor 设置分割线背景颜色
You can’t perform that action at this time.