我想改变RadioButton的圆圈颜色,我无法理解要设置的属性.我所拥有的背景颜色是黑色,因此它变得不可见.我想将圆圈的颜色设置为白色.
解决方法:
更简单,只需设置buttonTint颜色:(仅适用于API级别21或以上)
<Radiobutton androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:ID="@+ID/radio" androID:checked="true" androID:buttonTint="@color/your_color"/>
在你的values / colors.xml中,你的颜色在这种情况下是偏红的:
<color name="your_color">#e75748</color>
结果:
如果你想通过代码(也是API 21及以上)来做到这一点:
if(Build.VERSION.SDK_INT>=21){ colorStateList colorStateList = new colorStateList( new int[][]{ new int[]{-androID.R.attr.state_enabled}, //Disabled new int[]{androID.R.attr.state_enabled} //enabled }, new int[] { color.BLACK //Disabled ,color.BLUE //enabled } ); radio.setbuttonTintList(colorStateList);//set the color tint List radio.invalIDate(); //Could not be necessary}
总结 以上是内存溢出为你收集整理的android – 更改单选按钮的圆形颜色全部内容,希望文章能够帮你解决android – 更改单选按钮的圆形颜色所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)