myq_26 2012-10-08 05:37 采纳率: 16.7%
浏览 4412
已采纳

android -如何在radiobutton旁边添加view

我想在radio group中的radio button旁边设置view,我使用以下的代码没有成功。大家能帮忙找出错误吗?谢谢。

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:background="#FFFFFF">    

    <RadioGroup
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:checkedButton="@+id/view_completehistroy_rb"
            android:id="@+id/timeframe_group">

           <!-- View complete history Radio Button -->
           <RadioButton
                android:text="Complete History"
                android:textSize="16sp"
                android:layout_marginLeft="5dp"
                android:id="@+id/view_completehistroy_rb"
                android:textColor="#000000"
                />

            <!-- View history using date range Radio Button -->
            <RadioButton
                android:text="From"
                android:textSize="16sp"
                android:layout_marginLeft="5dp"
                 android:textColor="#000000"
                android:id="@+id/view_daterange_history_rb"/>

        </RadioGroup>

    <RelativeLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
          <!--Layout for Time selection  -->
          <LinearLayout 
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              android:layout_marginLeft="5dp"
              android:layout_toRightOf="@id/view_daterange_history_rb">                      

               <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="5dip"
                 android:layout_marginRight="5dip"
                 android:text="test1" 
                  android:textColor="#000000"
                 android:textSize="16sp"/>  

                <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="5dip"
                 android:layout_marginRight="5dip"
                 android:text="test2" 
                  android:textColor="#000000"
                 android:textSize="16sp"/>                  
          </LinearLayout>
    </RelativeLayout>
</LinearLayout>

enter image description here

  • 写回答

1条回答

  • myc_100 2012-10-08 07:05
    关注
     <RelativeLayout
                android:id="@+id/faxPannel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/emailPannel" >
    
                <RadioButton
                    android:id="@+id/radioButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="30dp" />
    
                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dip"
                    android:layout_marginRight="5dip"
                    android:layout_marginTop="10dp"
                    android:layout_toRightOf="@+id/radioButton"
                    android:layout_weight="1"
                    android:singleLine="true"
                    android:text="Label"
                    android:textColor="@color/Black"
                    android:textSize="16dp"
                    android:textStyle="bold" />
    
            </RelativeLayout>
    

    在活动处理oncheckChanged()事件来执行相关的功能。但是如果在布局中使用RadioGroup,就不能实现所要的效果。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记