Android Recyclerview GridLayoutManager column spacing
来源:互联网 发布:navicat for mysql语法 编辑:程序博客网 时间:2024/05/11 18:36
http://stackoverflow.com/questions/28531996/android-recyclerview-gridlayoutmanager-column-spacing
RecyclerViews support the concept of ItemDecoration: special offsets and drawing around each element. As seen in this answer, you can use
public class SpacesItemDecoration extends RecyclerView.ItemDecoration { private int space; public SpacesItemDecoration(int space) { this.space = space; } @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.left = space; outRect.right = space; outRect.bottom = space; // Add top margin only for the first item to avoid double space between items if (parent.getChildLayoutPosition(view) == 0) { outRect.top = space; } else { outRect.top = 0; } }}
Then add it via
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view);int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.spacing);mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));
0 0
- Android Recyclerview GridLayoutManager column spacing
- AndroidRecyclerviewGridLayoutManager列间距 - Android Recyclerview GridLayoutManager column spacing
- Android Recyclerview GridLayoutManager列间距
- RecyclerView+GridLayoutManager 间距
- android RecyclerView GridLayoutManager setSpanSizeLookup 不执行(不调用)
- android RecyclerView GridLayoutManager 滚动后导致第一行消失
- Android 自定义RecyclerView.ItemDecoration(GridLayoutManager布局下)
- RecyclerView使用GridLayoutManager间距设置
- RecyclerView使用GridLayoutManager间距设置
- Android-UI布局---RecyclerView学习(四)匹配GridLayoutManager的ItemDecoration
- Android随笔-GridLayoutManager
- RecyclerView GridLayoutManager 设置分割线 万能分割
- RecyclerView LinearLayoutManager GridLayoutManager StaggeredGridLayoutManager ScrollView 嵌套使用
- RecyclerView GridLayoutManager 使用遇到的问题
- RecyclerView使用GridLayoutManager实现两种item
- RecyclerView复杂布局动态管理GridLayoutManager
- RecyclerView+GridLayoutManager展示时,间距问题~!
- RecyclerView高度随Item自适应 GridLayoutManager和LinearLayoutManager都适用
- 腾讯8.3
- Java中byte基础类型的特殊性
- 我所理解的REST API
- MFC播放wav音频文件
- css文本
- Android Recyclerview GridLayoutManager column spacing
- 配置xampp php openssl遇到的问题
- 第四课、Scala集合
- Android图片处理实例介绍(图)
- 一步一步走进Linux HOOK API(二)
- 数据挖掘——数据分析挖掘体系
- 实现DedeCMS搜索结果页显示自定义字段
- OC语言:类方法以及构造器与访问器的用法
- android popuwindow点击外部窗口不消失