Recyclerview - Overlap items bottom to top

后端 未结 3 1242
鱼传尺愫
鱼传尺愫 2020-12-15 04:14

I have set the negative margin for items like this:-

ItemDecoration.java

public class ItemDecorator extends RecyclerView.ItemDecorat         


        
3条回答
  •  -上瘾入骨i
    2020-12-15 04:39

    As of 2020 there is new interface ChildDrawingOrderCallback. It defines the order of drawing elements in recycler view. Can be used like so:

    class BackwardsDrawingOrderCallback : RecyclerView.ChildDrawingOrderCallback {
        override fun onGetChildDrawingOrder(childCount: Int, i: Int) = childCount - i - 1
    }
    

    And then

    recyclerView.setChildDrawingOrderCallback(BackwardsDrawingOrderCallback())
    

    So there is no need to set neither reverse order nor stack from end anymore.

提交回复
热议问题