Bilal Haider Makki Bilal Haider Makki - 1 year ago 141
Android Question

Recyclerview - Overlap items bottom to top

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

public class ItemDecorator extends RecyclerView.ItemDecoration {
private final int mSpace;

public ItemDecorator(int space) {
this.mSpace = space;

public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
if (position != 0) = mSpace;

recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addItemDecoration(new ItemDecorator(-80));

This causes top item to stack lowest and next item after the top item overlaps it. I want top item to overlap its next item and so on.

Current View

enter image description here

Required View

enter image description here

Answer Source

Try this way and render your recycler view in reverse direction.

LinearLayoutManager layoutManager = new LinearLayoutManager(this);

Here is the working example GitHub Link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download