我试图在RelativeLayout中将几张Cardview放在彼此之下,但到目前为止它还没有完成。卡片视图全部在彼此之上,但是为所有这些设置了layout_below。这很奇怪,因为如果我没记错的话,它确实在过去有效。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com"
xmlns:android.support.v7.cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="something.something.fragments.RosterFragment"
android:id="@+id/relativeLayout"
android:background="@color/white"
tools:ignore="MergeRootFrame">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false"
android:id="@+id/rosterContainer0">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/cardViewMonday"
android:longClickable="true"
style="@style/InformationCard">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TitleLightBackground"
android:text="Maandag"
android:id="@+id/dateMonday" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rosterListViewMonday"
android:background="@color/white">
</ListView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/cardViewTuesday"
android:longClickable="true"
style="@style/InformationCard"
android:layout_below="@+id/cardViewMonday">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TitleLightBackground"
android:text="Dinsdag"
android:id="@+id/dateTuesday" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rosterListViewTuesday"
android:background="@color/white">
</ListView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/cardViewWednesday"
android:longClickable="true"
style="@style/InformationCard"
android:layout_below="@+id/cardViewTuesday">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TitleLightBackground"
android:text="Maandag"
android:id="@+id/dateWednesday" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rosterListViewWednesday"
android:layout_below="@+id/dateWednesday"
android:background="@color/white">
</ListView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/cardViewThursday"
android:longClickable="true"
style="@style/InformationCard"
android:layout_below="@+id/cardViewWednesday">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TitleLightBackground"
android:text="Maandag"
android:id="@+id/dateThursday" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rosterListViewThursday"
android:layout_below="@+id/dateThursday"
android:background="@color/white">
</ListView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/cardViewFriday"
android:longClickable="true"
style="@style/InformationCard"
android:layout_below="@+id/cardViewThursday">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TitleLightBackground"
android:text="Maandag"
android:id="@+id/dateFriday" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rosterListViewFriday"
android:layout_below="@+id/dateFriday"
android:background="@color/white">
</ListView>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
答案 0 :(得分:2)
注意何时复制 - 粘贴代码。
你所有的牌都有android:layout_alignParentTop =“true”
属性