当前位置:网站首页>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);
}
}
边栏推荐
- BUUCTF---Reverse---easyre
- Finally, there is no need to change a line of code! Shardingsphere native driver comes out
- Discussion on beegfs high availability mode
- Initial experience of addresssanitizer Technology
- 8086 instruction code summary (table)
- rt-thread i2c 使用教程
- 01 基础入门-概念名词
- Redisson bug analysis
- PHP and excel phpexcel
- Guangzhou's first data security summit will open in Baiyun District
猜你喜欢
随机推荐
(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of
Technology sharing | packet capturing analysis TCP protocol
2022年6月语音合成(TTS)和语音识别(ASR)论文月报
微信小程序常用集合
golang的超时处理使用技巧
Configuration and simple usage of the EXE backdoor generation tool quasar
Error analysis ~csdn rebound shell error
Node.js: express + MySQL实现注册登录,身份认证
Continuous test (CT) practical experience sharing
Period compression filter
JVM_ Common [interview questions]
PHP and excel phpexcel
夏志刚介绍
腾讯T2大牛亲自讲解,跳槽薪资翻倍
腾讯T3大牛手把手教你,大厂内部资料
Unity making plug-ins
Deep learning classification network -- zfnet
Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
Enumeration gets values based on parameters
PowerPivot - DAX (first time)