4.3使用样式。
在你xml中添加 即可(MyRadioButton是上面的命名)。
使用的布局实例如下:
?
- <?xml version="1.0" encoding="utf-8"?> <RadioGroup xmlns:android="http://www.easck.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:background="#aaaaaa" android:orientation="vertical" >
- <RadioButton
- style="@style/MyRadioButton" android:layout_width="wrap_content"
- android:layout_height="50dip" android:layout_marginTop="10dip"
- android:text="ABCD" />
- <RadioButton style="@style/MyRadioButton"
- android:layout_width="wrap_content" android:layout_height="50dip"
- android:layout_marginTop="10dip" android:text="EFGH" />
- </RadioGroup>
效果图:
5、相关说明。
对于style.xml中为什么给background加个图片而把button的图片设置为@null。这点其实要看你个人需要:
①如果你需要的样式是点选以后整个背景都改变那么改background的样式就可以了,而且把button的样式设置成@null,如果不设置的话当然是系统默认的样式。
②如果你只是想把系统样式中的那个带圈的图给换点的话那么改button的样式就可以了。











