我在relativelayout中有一个带有listview的linearlayout。 Listview是可见的,但父2按钮和textview不是。我无法弄清楚为什么。我尝试使用
将linearlayout设置为bottomandroid:layout_alignParentBottom="true"
但是没有用,任何人都可以告诉我为什么我只能看到我的列表视图而没有别的。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
<Button
android:id="@+id/exercise"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:text="@string/Exercise"
android:onClick="toStat"
/>
<Button
android:id="@+id/summary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:layout_toRightOf="@id/exercise"
android:text="@string/Summary"
android:onClick="toTraining"
/>
<LinearLayout 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:background="@color/blue">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:1)
因为你没有提到linearlayout应该在摘要按钮下面。因此它只是重叠textview和按钮。只需在LinearLayout中添加android:layout_below="@id/summary"
即可。还要将线性布局高度称为wrap_content。
<LinearLayout
android:layout_below="@id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/blue">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
</LinearLayout>