Overlap views inside Recyclerview

妖精的绣舞 提交于 2019-12-04 20:19:37

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

  1. The offset you're using in the item decorator from the example you used isn't large enough - hence the black gaps
  2. The order in which your linear layout manager is stacking your views is from the top, which means that the row below will draw over the cell above.

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!