RelativeLayout 中的 RadioGroup 和 TextView - RadioGroup 隐藏了 TextView

RadioGroup and TextView in a RelativeLayout - RadioGroup is hiding TextView

这就是我想要完成的。 textView 和下面的 radioButton 组,其中 radioButtons 以编程方式添加。我只能让 radioButton 组显示为 radioButtons 而不是 textViewradioButton 组占用了布局中的所有 space,textView 不可见。

我查看了 whosebug.com 上关于布局格式和显示的大量帖子,但仍然无法确定哪里出错了。

你能帮我解决这个问题吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </ListView>

    <TextView
        android:id="@+id/sample"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:background="@color/black"
        android:gravity="center"
        android:text="@string/sample"
        android:textColor="@color/white" />

    <RadioGroup
        android:id="@+id/radio_group"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:orientation="vertical" >
    </RadioGroup>

</RelativeLayout>

从相对布局更改为线性布局。 RelativeLayout 没有 'orientation' 属性,因为事物彼此 'Relative'。

添加 XML 后代的预期效果

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height=“wrap_content” >
</ListView>

<TextView
    android:id="@+id/sample"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="20dp"
    android:background="@color/black"
    android:gravity="center"
    android:text="@string/sample"
    android:textColor="@color/white" />

<RadioGroup
    android:id="@+id/radio_group"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:layout_below="@+id/sample”
    android:orientation="vertical" >
</RadioGroup>

</RelativeLayout>