A common RecyclerView divider , supports the LinearLayoutManager and the GridLayoutManager.
A common RecyclerView divider , supports the LinearLayoutManager and the GridLayoutManager.
一个通用的RecyclerView的分割线,支持LinearLayoutManager和GridLayoutManager。只要你能描述清楚每个position上下左右分割线的情况,原则上支持任意LayoutManager
将依赖加入你项目的build.gradle中:
compile 'com.yanyusong.y_divideritemdecoration:y_divideritemdecoration:2.0'新建一个对象实现抽象类 Y_DividerItemDecoration ,在 getDivider(int itemPosition) 中定义在itemPosition时条目的分割线情况,有无、颜色、宽度、startpadding 和 endpadding 。
…给RecyclerView添加刚才实现的ItemDecoration
recyclerView.addItemDecoration(new DividerItemDecoration(this)); Copyright 2017 yanyusong
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.No open issues yet, or sync has not completed.