I created RadioButton
and CheckBox
in LinearLayout
programatically. But, now I want to change radio button\'s color and check boxes\'s
For CheckBox
, replace your CheckBox
with AppCompatCheckBox
and call following method:
public static void setCheckBoxColor(AppCompatCheckBox checkBox, int uncheckedColor, int checkedColor) {
ColorStateList colorStateList = new ColorStateList(
new int[][] {
new int[] { -android.R.attr.state_checked }, // unchecked
new int[] { android.R.attr.state_checked } // checked
},
new int[] {
uncheckedColor,
checkedColor
}
);
checkBox.setSupportButtonTintList(colorStateList);
}
I think it should be similar for RadioButton
. You can check declared attributes in android.R.attr
and change the code.