The question is very simple, but due to the fact that I do not know English well, I myself cannot find the answer to the question. In general, I have a CheckBox , no matter in which position I have it, the main thing is that it is not clickable because the code called the setEnabled(false) method for it and it turns out that the CheckBox highlighted in gray, that is, the color of the marked and not the color of the unmarked (I'm talking about colors defined in the style). I understand that there should be an attribute for the style that sets this color, only I cannot find this attribute. Help, thanks in advance!
|
1 answer
It's simple, you can do this:
Suppose your CheckBox :
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/checkbox_background" /> And here is the checkbox_background.xml file itself in which the parameters of the CheckBox type are stored, depending on its state (it should be in the drawable folder):
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/checkbox_on_background_focus_yellow" /> <item android:state_checked="false" android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/checkbox_off_background_focus_yellow" /> <item android:state_checked="false" android:state_enabled="true" android:drawable="@drawable/checkbox_off_background" /> <item android:state_checked="true" android:state_enabled="true" android:drawable="@drawable/checkbox_on_background" /> <item android:state_checked="false" android:state_enabled="false" android:drawable="@drawable/checkbox_off_background" /> <item android:state_checked="true" android:state_enabled="false" android:drawable="@drawable/checkbox_on_background" /> </selector> Here each item is responsible for some state (which one is described by the parameters inside the item ). And the parameter you are interested in here is android:state_enabled="false
So the last 2 item 'a inside selector ' a are responsible for the CheckBox view 'and in the disabled state in the "not checked" and "checked" positions, respectively.
- This checkbox_background.xml can also be specified in style as background - Juis Kel
|
android:state_enabled? - post_zeewCheckBoxwhen placed in alayoutfile? - post_zeew<!-- Disabled states -->. - post_zeew