简体   繁体   English

Android单选按钮组

[英]Android radio button group

Can I get a RadioButton group in the following way? 我可以通过以下方式获得RadioButton组吗?

x x x
x x x
x x x

Now I am getting it all in one line - either vertical or horizontal: 现在,我将所有内容全部放在一行中-垂直或水平:

x x x x x x    or   x
                    x
                    x
                    x
                    x
                    x

In horizontal its going to the next line but its not in fixed position. 在水平方向上它会转到下一行,但是它不在固定位置。

Below code is just to meet with the standards of posting. 下面的代码只是为了满足发布的标准。

<RadioGroup
        android:id="@+id/calradioGroup4.1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:orientation="vertical" >


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

        <RadioButton
            android:id="@+id/radio0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="0-5" />

        <RadioButton
            android:id="@+id/radio2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="11-15" />
<RadioGroup
    android:id="@+id/r_A"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1" >

        <RadioButton
            android:id="@+id/r_A0"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.50"
            android:drawableLeft="@drawable/gr_icon"
            android:text="A0"
            android:textColor="#000000" />

        <RadioButton
            android:id="@+id/r_A1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.50"
            android:drawableLeft="@drawable/gr_icon"
            android:text="A1"
            android:textColor="#000000" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/r_B0"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableLeft="@drawable/gr_icon"
            android:text="B0"
            android:textColor="#000000" />

        <RadioButton
            android:id="@+id/r_B1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableLeft="@drawable/gr_icon"
            android:text="B1"
            android:textColor="#000000" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/r_C0"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableLeft="@drawable/gr_icon"
            android:text="C0"
            android:textColor="#000000" />

        <RadioButton
            android:id="@+id/r_C1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableLeft="@drawable/gr_icon"
            android:text="C1"
            android:textColor="#000000" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/r_D0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/gr_icon"
            android:text="D0"
            android:textColor="#000000" />

        <RadioButton
            android:id="@+id/r_E0"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableLeft="@drawable/gr_icon"
            android:text="E1"
            android:textColor="#000000" />
    </LinearLayout>
</RadioGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM