Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 1.29 KB

README.md

File metadata and controls

44 lines (36 loc) · 1.29 KB

说明

这是一个针对recyclerview的库,可提供简单的粘性头部,列表间距功能

使用

1.跟目录的build.gradle

maven { url = "https://dl.bintray.com/lamandys/repository" }
  1. 要使用的module.gradle
    implementation 'com.lamandys:listSimpleDecoration:1.0.0'
  1. 代码中加入
recyclerList.addItemDecoration(LineDecoration.default())

或者是 粘性头部:

val stickyDecoration = StickyDecoration.Builder()
            .stickyTextColor(Color.parseColor("#456EFF"))
            .stickyTextSize(14)
            .stickyItemBackgroundColor(Color.parseColor("#5E6D82"))
            .stickyItemHeight(150)
            .stickTextMarginLeft(100f)
            .withStickyHoverBuilder(object : StickyHoverBuilder {
                override fun isFirstItemInGroup(position: Int): Boolean {
                    val date = viewModel.myListData.value?.get(position) ?: return false
                    return date.isFirstItemInGroup
                }

                override fun groupName(position: Int): String {
                    val date = viewModel.myListData.value?.get(position) ?: return ""
                    return date.groupName
                }

            })
            .build()
        recyclerList.addItemDecoration(stickyDecoration)