I have a RelativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
tools:context="com.pinder.moffel.pinder.DeleteActivity"
android:id="@+id/deleteBackground">
<com.andtinder.view.CardContainer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tinderview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0"/>
</RelativeLayout>
I'm using the library AndTinder: https://github.com/kikoso/Swipeable-Cards
I already know how to add a new card, but the problem is, because a new layout is being added, the new card get shown on top of the other views.
I'd like to add 3 cards when the activity loads and then add a new card behind all other cards when a card is swiped away.
How do I inflate a new view behind all other views in a RelativeLayout?
Some additional code:
JAVA code
SimpleCardStackAdapter adapter = null;
CardContainer mCardContainer = (CardContainer) findViewById(R.id.tinderview);
adapter = new SimpleCardStackAdapter(this);
CardModel newCard = new CardModel(null, null, image); //image is retrieved before
adapter.add(newCard); //the new card will now be on top of the others, i want it to be behind them
mCardContainer.setAdapter(adapter);
XML view that is being added
<RelativeLayout
android:id="@+id/global_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignWithParentIfMissing="true"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter"
tools:src="@drawable/picture1"/>
<View
android:id="@+id/divider_bottom"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="@id/image"
android:background="@color/card_outline" />
<View
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_alignBottom="@+id/layoutButton"
android:layout_below="@+id/divider_bottom"
android:background="@color/card_bg"
/>
<!-- An invisible view aligned to the center of the parent. Allows other
views to be arranged on either side -->
<LinearLayout
android:id="@+id/layoutButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/divider_bottom"
android:gravity="center"
>
<ImageButton
android:id="@+id/image_1"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/denied"
android:padding="10dp"
android:layout_marginRight="80dp"/>
<ImageButton
android:id="@+id/image_2"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/heart"
android:padding="10dp"
android:layout_alignParentRight="true" />
</LinearLayout>
</RelativeLayout>
In another question (How to inflate a view behind another) the answer states that it is impossible to add views behind others, but I think there has to be a way to accomplish this.