回收站视图中最后几个项目的更改跨度计数

我正在尝试实现巴士预订座位布局,并完成此座位布局,我正在使用跨度计数为4的Gridlayoutmanager。但是我需要得到跨度计数为5的最后一排座位。请帮忙。

我尝试过获取跨度大小,但无法正常工作。


慕的地6264312
浏览 59回答 1
1回答

鸿蒙传说

因此,您需要在一列中包含 4 或 5 行。将一列划分为(4 * 5)或20个空格。然后给最后5个座位的5个空间(20/4),并为其他座位提供4个空间(20/5)。例如:GridLayoutManager glm = new GridLayoutManager(getContext(), 20);&nbsp; &nbsp; glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {&nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; public int getSpanSize(int position) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (position < TotalSeat-5)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 5;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else return 4;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; });我想你可能会理解我的想法。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java