Reputation: 27255
I have two cards views, I want to place one above the other but the end result is that they are placed on top of each other:
This is the XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/entryTypeCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/entryChoiceSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
</android.support.v7.widget.CardView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:id="@+id/currencySpinnerLayout"
android:orientation="vertical"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/currencyTypeCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/currencyChoiceSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
</android.support.v7.widget.CardView>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<AutoCompleteTextView
android:id="@+id/personNameTextField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
What am I doing wrong?
Upvotes: 1
Views: 2238
Reputation: 47817
Assign some id to first RelativeLayout
<RelativeLayout
android:id="@+id/first_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
and then used
android:layout_below="@+id/first_layout"
to second layout.
Upvotes: 3