当前位置:   article > 正文

自定义RadioButton样式

自定义radiobutton样式

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>
  • 1
  • 2
  • 3
  • 4
  • 5
  1. 在styles里面引用自定义样式
<style name="RadioButtonStyles">
    <item name="android:button">@drawable/reason_radiobtn_style</item>
</style>
  • 1
  • 2
  • 3
  1. 在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"/>;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

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

技术共享群:195109527

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号