0

I want to make the views inside horizontal recycleView to be intersected by each other with some percentage like this image. what is the best approach of doing this?

overlapping images

Bobbake4
  • 24,509
  • 9
  • 59
  • 94
Alnour Alharin
  • 320
  • 3
  • 13
  • 1
    Possible duplicate of [How to Overlap items in LinearLayoutManager - RecyclerView (like stacking cards)](http://stackoverflow.com/questions/27633454/how-to-overlap-items-in-linearlayoutmanager-recyclerview-like-stacking-cards) – OneCricketeer Jan 25 '17 at 00:16

1 Answers1

1

Edit: I erased the wrong answer, this one work perfectly.

You need to create the following class(it can be inner class if you are gone use of in one activity).

public class OverlapDecoration extends RecyclerView.ItemDecoration {

    private final static int horizontalOverlap = -100;

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        final int itemPosition = parent.getChildAdapterPosition(view);
        if (itemPosition == 0) { return; }
        outRect.set(horizontalOverlap, 0, 0, 0);
        }
    }

Then you add an Item Decoration to your recyclerView.

mRecyclerView.addItemDecoration(new OverlapDecoration());
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245