当前位置:网站首页>Recyclerview GridLayout bisects the middle blank area
Recyclerview GridLayout bisects the middle blank area
2022-07-06 20:21:00 【CodingForAndroid】
/**
* @description recyclerview gridlayout Divide the middle blank area equally
*/
class UserGradeItemDecoration(val width:Int,val itemWidth: Int, val columns: Int,val topPadding:Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
var position = parent.getChildAdapterPosition(view);
var totalCount = parent.adapter?.itemCount;
// It can be adapted to any number of columns ( Just put it down )
var w = (width - itemWidth * columns) / (columns * (columns-1));
var p = position % columns;
outRect.left = (w*p);
}
}
边栏推荐
- 腾讯架构师首发,2022Android面试笔试总结
- Basic knowledge of lists
- Linear distance between two points of cesium
- JMeter server resource indicator monitoring (CPU, memory, etc.)
- An East SMS login resurrection installation and deployment tutorial
- Rhcsa Road
- 设计你的安全架构OKR
- Special topic of rotor position estimation of permanent magnet synchronous motor -- Summary of position estimation of fundamental wave model
- Case ① | host security construction: best practice of 3 levels and 11 capabilities
- A5000 vgpu display mode switching
猜你喜欢
Rhcsa Road
[network planning] Chapter 3 data link layer (4) LAN, Ethernet, WLAN, VLAN
A5000 vgpu display mode switching
报错分析~csdn反弹shell报错
深度学习分类网络 -- ZFNet
Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
Cesium 点击绘制圆形(动态绘制圆形)
rt-thread i2c 使用教程
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
随机推荐
新一代垃圾回收器—ZGC
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
Discussion on beegfs high availability mode
Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
Groovy基础语法整理
In unity space, an object moves around a fixed point on the sphere at a fixed speed
报错分析~csdn反弹shell报错
Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution
持续测试(CT)实战经验分享
02 basic introduction - data package expansion
数字三角形模型 AcWing 1018. 最低通行费
设计你的安全架构OKR
PowerPivot——DAX(初识)
【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和
Cesium 点击绘制圆形(动态绘制圆形)
使用ssh连接被拒
Standardized QCI characteristics
Tencent T3 teaches you hand in hand. It's really delicious
beegfs高可用模式探讨
Is it difficult for small and micro enterprises to make accounts? Smart accounting gadget quick to use