有没有办法让水平放置一个无线电组?

Ted*_*tel 35 android

我在收音机组内有2个单选按钮.现在他们垂直排队.我尝试将它们放在一个水平容器中,但它并没有后悔.

有没有办法让一组无线电按钮按顺序排列?

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<RadioGroup
    android:id="@+id/radioSex"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RadioButton
        android:id="@+id/radioChats"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Chats" 
        android:checked="true" />

    <RadioButton
        android:id="@+id/radioPlayers"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Players" 
        android:checked="true" />

    </RadioGroup>

<Button android:text="Home" 
    android:id="@+id/buthome"
     android:paddingTop="-15dip"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" />

    <Button android:text="Players" 
       android:id="@+id/butplayers"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" />

  <TextView 
        android:id="@+id/viewActivePlayer" 
      android:layout_width="wrap_content" 
         android:layout_height="wrap_content"
      android:text="TedP" 
      android:layout_gravity="right" 
         android:textColor="#fffff109"
    android:textSize="26dip" />    
Run Code Online (Sandbox Code Playgroud)

azg*_*fer 81

添加android:orientation="horizontal"RadioGroup标签:

<RadioGroup
   android:id="@+id/radioSex"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" 
   android:orientation='horizontal'>
Run Code Online (Sandbox Code Playgroud)


arl*_*dia 10

您也可以通过编程方式设置:

myRadioGroup.setOrientation(LinearLayout.HORIZONTAL);
Run Code Online (Sandbox Code Playgroud)