Android中如何设置RadioButton在文字的右边,图标在左边?
现状:Android 默认的 RadioGroup 中 RadioButton和 文字 Text 的位置关系是 Radiobutton在文字左边。且只有点击Radiobutton才能触发点击事件,文字不能触发监听事件。
目标:外观UI上要和 RadioGroup 的保持一致,但是逻辑上除了要实现单选功能外,还要能根据逻辑要求Disable掉某一条RadioButton(不能点击,按钮和文字灰白)。
一般的RadioGroup效果图:
解决方案:
一、利用Radiobutton的属性
1.android:button="@null"将图标给隐藏
2.再用android:drawableRight="@android:drawable/btn_radio"在右边生成一个图标,再用android:text="文字内容"在隐藏图标的位置显示文字。
3.根据逻辑在代码中设置Radiobutton的enable、focusable、clickable的属性。
详细参见博客:http://blog.csdn.net/sunnyfans/article/details/7901592