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?
Asked
Active
Viewed 113 times
0
-
1Possible 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 Answers
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

Henrique César Madeira
- 818
- 7
- 15
-
I set it to 100 pixels (also tried horizontal) but the output was the same as in this photo https://drive.google.com/file/d/0BxMISdowfennM25hbndOck9MSFk/view?usp=sharing – Alnour Alharin Jan 24 '17 at 22:21
-
I change the answer now it might work exactly like you want. – Henrique César Madeira Jan 25 '17 at 00:15