【发布时间】:2015-06-19 15:27:16
【问题描述】:
这就是我想要完成的。 textView 及其下方的 radioButton 组,其中radioButtons 以编程方式添加。我只能得到radioButton 组与radioButtons 而不是textView。 radioButton 组占用了布局中的所有空间,textView 不可见。
我在 stackoverflow.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>
【问题讨论】:
-
@MarkKeen 的回答是正确的。你应该接受它。
-
在您的 Radio 组中添加 android:layout_below="@+id/sample" 线路
-
@Harish - 感谢您的回复。我添加了您建议的更改以及修改后的 android:layout_height 到 textView 的“wrap_content”。它现在按预期工作! :)
标签: android android-layout android-radiogroup