问题描述
这是我试图完成的任务。 A 的TextView
和下一个单选
组,其中单选按钮
编程方式添加。我能够得到的只有与单选按钮
显示单选
组,而不是的TextView
。 单选
组占用了布局所有的空间和的TextView
是看不见的。
我已经看过成无数的职位上stackoverflow.com格式化和布局显示,但仍无法弄清楚我在哪儿做的错误。
您能帮我这个问题?
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=横向> < ListView控件
机器人:ID =@机器人:ID /列表
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
< /&的ListView GT; <的TextView
机器人:ID =@ + ID /样本
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:layout_gravity =中心
机器人:layout_marginBottom =20dp
机器人:layout_marginTop =20dp
机器人:背景=@彩色/黑白
机器人:比重=中心
机器人:文字=@字符串/样品
机器人:文字颜色=@色/白/> < RadioGroup中
机器人:ID =@ + ID / radio_group
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@色/白
机器人:方向=垂直>
< / RadioGroup中>< / RelativeLayout的>
添加XML是按预期工作为后人
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=横向>< ListView控件
机器人:ID =@机器人:ID /列表
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
< /&的ListView GT;<的TextView
机器人:ID =@ + ID /样本
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:layout_gravity =中心
机器人:layout_marginBottom =20dp
机器人:layout_marginTop =20dp
机器人:背景=@彩色/黑白
机器人:比重=中心
机器人:文字=@字符串/样品
机器人:文字颜色=@色/白/>< RadioGroup中
机器人:ID =@ + ID / radio_group
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@色/白
机器人:layout_below =@ + ID /样本
机器人:方向=垂直>
< / RadioGroup中>< / RelativeLayout的>
This is what am trying to accomplish. A textView
and beneath that a radioButton
group in which radioButtons
are added programmatically. Am able to get only the radioButton
group displayed with radioButtons
and not the textView
. radioButton
group is taking up all the space in layout and textView
is invisible.
I have looked into numerous posts on stackoverflow.com on formatting and displaying in layout but still could not figure where am making the mistake.
Could you please help me with the issue?
<?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>
Adding XML that is working as expected for posterity
<?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>
这篇关于RadioGroup中和的TextView在RelativeLayout的 - RadioGroup中是隐藏的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!