如何在Android中通过编程方式更改复选框边框颜色? [英] How to change check box border color via programmatically in android?
问题描述
在我的XML包含一个复选框
。如何在Android中通过编程方式更改复选框边框颜色。
In my XML contains one CheckBox
. How to change check box border color via programmatically in android.
我的样本屏幕截图是在这里
<一href="http://0prlra.blu.livefilestore.com/y1pDwsdCkcNQqbb_Ut3y4-71FZ9d21K-BrKa2MIVSMpkq7ZENj23MWl9JLLQYShM1Ik5mxS-k8aug1frYjW-I4S0Q/checkbox-css.jpg"相对=nofollow标题=屏幕快照>截图
My Sample ScreenShot is here
ScreenShot
感谢。
推荐答案
您可以设置 check.setButtonDrawable(mContext.getResources()。getDrawable(
R.drawable.radio));
you can set check.setButtonDrawable(mContext.getResources().getDrawable(
R.drawable.radio));
在 radio.xml
您可以设置任何背景的复选框。
in radio.xml
you can set any background to your check box.
在radio.xml
in radio.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/option_unselected" android:state_checked="false"/>
<item android:drawable="@drawable/option_selected" android:state_checked="true"/>
在这里option_selected和option_selected是图形选择和unslected状态。
here option_selected and option_selected are the graphics for selected and unslected state.
了解更多,您可以检查的http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
for more you can check http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
这篇关于如何在Android中通过编程方式更改复选框边框颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!