当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢

Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech

小孩子学什么编程?

Learn to punch in Web

Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great

某东短信登录复活 安装部署教程

5. Nano - Net in wireless body: Top 10 "is it possible?" Questions

OLED屏幕的使用

Standardized QCI characteristics

系统与应用监控的思路和方法

设计你的安全架构OKR
随机推荐
Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model
深度学习分类网络 -- ZFNet
Poj3617 best cow line
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
设计你的安全架构OKR
Appx code signing Guide
RT-Thread 组件 FinSH 使用时遇到的问题
案例 ①|主机安全建设:3个层级,11大能力的最佳实践
How to select several hard coded SQL rows- How to select several hardcoded SQL rows?
Tencent byte and other big companies interview real questions summary, Netease architects in-depth explanation of Android Development
【每周一坑】输出三角形
技术分享 | 抓包分析 TCP 协议
8086指令码汇总表(表格)
看过很多教程,却依然写不好一个程序,怎么破?
5. 无线体内纳米网:十大“可行吗?”问题
B-jiege's tree (pressed tree DP)
Period compression filter
Redisson bug analysis
枚举根据参数获取值
Wonderful coding [hexadecimal conversion]