当前位置:网站首页>recyclerview gridlayout 平分中间空白区域
recyclerview gridlayout 平分中间空白区域
2022-07-06 12:20:00 【CodingForAndroid】
/**
* @description recyclerview gridlayout 平分中间空白区域
*/
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;
// 可以适配任意列数(只要放的下)
var w = (width - itemWidth * columns) / (columns * (columns-1));
var p = position % columns;
outRect.left = (w*p);
}
}
边栏推荐
- Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great
- AsyncHandler
- AsyncHandler
- Continuous test (CT) practical experience sharing
- 数字三角形模型 AcWing 1018. 最低通行费
- 微信小程序常用集合
- POJ 3207 Ikki's Story IV – Panda's Trick (2-SAT)
- Wechat applet common collection
- Example of applying fonts to flutter
- 报错分析~csdn反弹shell报错
猜你喜欢
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
Tencent Android development interview, basic knowledge of Android Development
Discussion on beegfs high availability mode
Anaconda安裝後Jupyter launch 沒反應&網頁打開運行沒執行
腾讯架构师首发,2022Android面试笔试总结
Tencent byte and other big companies interview real questions summary, Netease architects in-depth explanation of Android Development
Standardized QCI characteristics
深度学习分类网络 -- ZFNet
腾讯T3手把手教你,真的太香了
【GET-4】
随机推荐
5. 无线体内纳米网:十大“可行吗?”问题
Appx代码签名指南
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
使用ssh连接被拒
Cesium 两点之间的直线距离
5. Wireless in vivo nano network: top ten "feasible?" problem
句号压缩过滤器
Deep learning classification network -- zfnet
Color is converted to tristimulus value (r/g/b) (dry stock)
Le lancement du jupyter ne répond pas après l'installation d'Anaconda
腾讯T2大牛亲自讲解,跳槽薪资翻倍
Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
8086指令码汇总表(表格)
广州首个数据安全峰会将在白云区开幕
棋盘左上角到右下角方案数(2)
Finally, there is no need to change a line of code! Shardingsphere native driver comes out
青龙面板白屏一键修复
A5000 vGPU显示模式切换
Transformer model (pytorch code explanation)
夏志刚介绍