您的位置:首页 > Web前端 > CSS

自定义RadioButton样式

2017-03-04 22:12 176 查看
Android如何自定义RadioButton的样式

1.在drawable文件夹下定义样式

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/reason_radio_btn_img_sel" android:state_checked="true" android:state_enabled="true"></item>
<item android:drawable="@mipmap/reason_readio_btn_nor" android:state_checked="false" android:state_enabled="true"></item>
</selector>


在styles里面引用自定义样式

<style name="RadioButtonStyles">
<item name="android:button">@drawable/reason_radiobtn_style</item>
</style>


在xml中引用

<RadioButton
android:id="@+id/item_reason_radio_btn"
style="@style/RadioButtonStyles"
android:layout_width="@dimen/dimen_22dp"
android:layout_height="@dimen/dimen_22dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>


这样RadioButton就可以达到你想要的效果了。

技术共享群:195109527
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android radio button