1

I have a RecyclerView and inside it I want to put CardViews. Now I want these CardViews to overlap themselves like inside a Stackview, but i cannot find a solution to let my view look like this.

The result should look like the reminder app from iOS (see the screenshot) or like a deck of cards. The user should be able to scroll through the cardviews and drag them on the position he wants them to have.

Does anyone have an idea how to solve this problem? Or is there any library that could help me to let my view look like this? I have already tried an custom ItemDecoration but only the visible items of the RecyclerView are shifted and so the RecyclerView has a wrong behavior on scrolling.

iOS reminder app

Cimoe
  • 580
  • 6
  • 21
  • I would suggest looking at something like this: http://stackoverflow.com/questions/27633454/how-to-overlap-items-in-linearlayoutmanager-recyclerview-like-stacking-cards – Bradley Wilson Mar 20 '17 at 15:40

1 Answers1

3

You can achieve overlapping of items by using negative bottom margins for your item layout. See the documentations for details.

For example:

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="-10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Test"/>

    </android.support.v7.widget.CardView>
Doron Yakovlev Golani
  • 5,188
  • 9
  • 36
  • 60