RaidoButton的一些小应用

Android 中许多选择场景中都是一组单项选择功能,那为了方便大家都是想到用RadioGrou+RadioButton的组合实现单个被选中的状态,而RadioButton控件默认的选中圆圈是在左边,可是人家UI大师可不管你,就是把选中图放在文字的右边了。放弃用它吧,自己写有感觉太麻烦,后来发现原来可以这么做。

每个控件的选中与没选中原理都是一样的,都是通过checked属性来判断的,当然还有其他的clickable pressed等等属性都是一样的.

RadioButton 有这么一个drawable属性 有上下左右四个,哦了,那就把系统默认的圈圈去掉用drawable自定义一下。(去掉RaidoButton默认圈圈是把button属性设置为@null就ok了)。自己写一个selector放在drawableRight中 就ok了。很容易啊,赶紧记录下,不能再忘了大笑

<RadioButton
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:button="@null"
    android:drawableLeft="@mipmap/weixin"
    android:padding="10dp"
    android:drawableRight="@android:drawable/btn_radio"
    android:text="微信支付"
    android:textColor="@color/color_black_text"
    android:textSize="@dimen/size_common_text" />

猜你喜欢

转载自blog.csdn.net/My_Jack/article/details/53396210