当前位置:网站首页>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);
}
}
边栏推荐
- “罚点球”小游戏
- Synchronization of data create trigger synchronization table for each site
- Zoom with unity mouse wheel: zoom the camera closer or farther
- Error analysis ~csdn rebound shell error
- 设计你的安全架构OKR
- 01 basic introduction - concept nouns
- Special topic of rotor position estimation of permanent magnet synchronous motor -- Summary of position estimation of fundamental wave model
- 【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和
- What happened to the kernel after malloc() was transferred? Attached malloc () and free () implementation source
- Oceanbase Community Edition OBD mode deployment mode stand-alone installation
猜你喜欢
Tencent T2 Daniel explained in person and doubled his job hopping salary
Tencent architects first, 2022 Android interview written examination summary

Cesium 点击绘制圆形(动态绘制圆形)

小孩子学什么编程?

rt-thread i2c 使用教程

Cesium Click to draw a circle (dynamically draw a circle)

电子游戏的核心原理

Error analysis ~csdn rebound shell error

【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN

Leetcode question 283 Move zero
随机推荐
JS implementation force deduction 71 question simplified path
持续测试(CT)实战经验分享
Tencent T4 architect, Android interview Foundation
逻辑是个好东西
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
Tencent T3 teaches you hand in hand. It's really delicious
B-杰哥的树(状压树形dp)
Unity makes AB package
Discussion on beegfs high availability mode
报错分析~csdn反弹shell报错
BUUCTF---Reverse---easyre
Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
String length limit?
Node. Js: express + MySQL realizes registration, login and identity authentication
JMeter server resource indicator monitoring (CPU, memory, etc.)
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution
【Yann LeCun点赞B站UP主使用Minecraft制作的红石神经网络】
RT thread I2C tutorial
recyclerview gridlayout 平分中间空白区域