2015-07-01 117 views
1

我有兩個卡視圖,我要放置一個在另一個之上,但最終的結果是,他們被放置在彼此的頂部上:CardView佈局重疊

enter image description here

這是XML代碼:

<?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" 
     ... 

我在做什麼錯?

回答

3

分配一些id來第一RelativeLayout

<RelativeLayout 
android:id="@+id/first_layout" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

,然後用於

android:layout_below="@+id/first_layout" 

至第二佈局。

+1

謝謝你。我永遠不會理解佈局和他們的屬性:( –

+0

@ojonugwaochalifu喲歡迎!!!!! –

+1

接受即將推出... –