我有两个卡片 View ,我想将一个放在另一个上面,但最终结果是它们彼此重叠:
这是 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"
...
我做错了什么?
最佳答案
为第一个 RelativeLayout
分配一些 id
<RelativeLayout
android:id="@+id/first_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
然后使用
android:layout_below="@+id/first_layout"
到第二个布局。
关于android - CardView 布局重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31158930/