当前位置:网站首页>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);
}
}
边栏推荐
- PowerPivot——DAX(初识)
- Configuration and simple usage of the EXE backdoor generation tool quasar
- 范式的数据库具体解释
- Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great
- redisson bug分析
- [cloud lesson] EI lesson 47 Mrs offline data analysis - processing OBS data through Flink
- String长度限制?
- Tencent T4 architect, Android interview Foundation
- SSH connection denied
- Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
猜你喜欢

持续测试(CT)实战经验分享

01 基础入门-概念名词

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

22-07-05 七牛云存储图片、用户头像上传

JMeter server resource indicator monitoring (CPU, memory, etc.)

Example of applying fonts to flutter

【GET-4】
腾讯T4架构师,android面试基础
![[Yann Lecun likes the red stone neural network made by minecraft]](/img/95/c3af40c7ecbd371dd674aea19b272a.png)
[Yann Lecun likes the red stone neural network made by minecraft]

HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
随机推荐
Maximum likelihood estimation and cross entropy loss
Example of shutter text component
Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech
Digital triangle model acwing 1018 Minimum toll
Database specific interpretation of paradigm
Anaconda安裝後Jupyter launch 沒反應&網頁打開運行沒執行
Tencent T2 Daniel explained in person and doubled his job hopping salary
22-07-05 upload of qiniu cloud storage pictures and user avatars
Tencent Android development interview, basic knowledge of Android Development
青龙面板白屏一键修复
腾讯T3大牛手把手教你,大厂内部资料
8086指令码汇总表(表格)
Unity makes AB package
Learn to punch in Web
案例 ①|主机安全建设:3个层级,11大能力的最佳实践
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
枚举根据参数获取值
POJ 3207 Ikki' s Story IV – Panda' s Trick (2-SAT)
mod_ WSGI + pymssql path SQL server seat
Notes on beagleboneblack