Checkbox,RadioButton按钮位置修改

先百度了一下
https://blog.csdn.net/sunnyfans/article/details/7901592
确实也能解决问题,但是带来了2个问题。

自己项目使用的是Theme.AppCompat主题
使用起来还是有点问题,但是方法上可以借鉴一下。只是使用样式有点问题。

android:drawableRight="@android:drawable/btn_radio"有点老了,不好看。

于是自己跟入android源码查看了下Theme.AppCompat主题下默认的样式。

   <style name="Base.Widget.AppCompat.CompoundButton.RadioButton" parent="android:Widget.CompoundButton.RadioButton">
        <item name="android:button">?android:attr/listChoiceIndicatorSingle</item>
        <item name="android:background">?attr/controlBackground</item>
    </style>

所以可以直接这样子

android:drawableRight="?android:attr/listChoiceIndicatorSingle"

这里的backrgound是一个默认的背景色,点击后有一个水波纹,但是是一个圆圈。不太满足我的需求,我需要一个横条型的水波纹。

所以

android:background="?attr/selectableItemBackground"
    原文作者:javalong
    原文地址: https://www.jianshu.com/p/abd0e90f8e41
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞