RadioGroup中嵌套LinearLayout布局无法实现按钮单选

为了实现两个单选按钮水平放置,于是想加入一个LinearLayout的布局,结果发现两个单选按钮竟同时被选上了,初学不太了解RadioGroup的特性,原来只需在RadioGroup中加入一句android:orientation="horizontal"就能让其包含的单选按钮水平了,不需要用到布局的嵌套。

 <RadioGroup
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal">
            
            <RadioButton
                android:id="@+id/boy"
                android:text="男"
                android:textSize="22sp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <RadioButton
                android:id="@+id/girl"
                android:text="女"
                android:textSize="22sp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                />

   </RadioGroup>

猜你喜欢

转载自blog.csdn.net/weixin_39577771/article/details/88560488
今日推荐