我应该如何实施RadioGroup?

时间:2020-06-24 05:26:40

标签: android android-studio android-layout radio-button android-xml

我有一个需要2个选项的布局,您必须选择其中一个,所以我们需要在其中使用RadioGroup,但是每个RadioButton的内部都有一个Text和一个Image,我在RadioButton中查找了重叠的图像,然后执行通过选择器(可绘制)进行操作,但我无法完成。

布局文件:

enter image description here

1 个答案:

答案 0 :(得分:0)

如何使用drawableTop来显示RadioButton来显示图标?

 <RadioButton
    android:id="@+id/rad_home"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="@drawable/rad_background"
    android:button="@null"
    android:drawableTop="@drawable/home_icon"
    android:gravity="center"
    android:text="Home"
    android:textColor="@drawable/text_background"
    android:textSize="@dimen/rad_text_size" >