Recyclerview内部的重叠视图 [英] Overlap views inside Recyclerview

查看:224
本文介绍了Recyclerview内部的重叠视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现图片中所附的布局.我已经尝试过 StackOverFlow答案

Hi I need to implement the layout as attached in pic. I have tried this StackOverFlow answer

但是创建的结果视图如下所示

but the resultant view get created as attached below

我需要右下角位于recyclerview的下一个单元格上方.

I need that bottom right corner to be above next cell of recyclerview.

请建议如何使该单元格的顶部位于上一个单元格的下方.

Please suggest how can make top of the cell below previous cell.

推荐答案

您似乎已经关闭.您在这里看到的问题是:

It looks like you're close. The problems you're seeing here are:

  1. 您在示例装饰器中使用的偏移量与所使用的示例相比不够大-因此存在黑色间隙
  2. 线性布局管理器堆叠视图的顺序是从顶部开始的,这意味着下面的行将绘制在上面的单元格上.

要解决此问题,请首先添加更多的偏移量以消除黑色间隙.

To fix this, first, add a bit more offset to get rid of the black gaps.

第二,在LinearLayoutManager上调用setReverseLayout(true)(也可以通过构造函数完成)-这将使其首先绘制底部的项目,以便单元格将在下面的单元格上方绘制.

Second, call setReverseLayout(true) on your LinearLayoutManager (can also be done via the constructor) - this will make it draw the bottom items first, so that the cells will draw above the cells below.

此外,您可能需要尝试使用视图的高程来获得整齐的阴影效果,请确保索引N的行的高程比索引N + 1的行的高程.您可以通过在适配器中绑定每个视图时调用myView.setElevation((getItemCount() - position) * SOME_DP_AMOUNT)来实现此目的.

Also, you might want to play around with the elevation of the views to get that neat shadow effect, making sure that a row at index N will have a higher elevation than a row at index N+1. You could do this by calling myView.setElevation((getItemCount() - position) * SOME_DP_AMOUNT) when binding each view in your adapter.

这篇关于Recyclerview内部的重叠视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆