我该怎么做?选中时RadioButton的颜色和文字颜色发生变化
这是我用它来改变文字颜色:
maleRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
maleRadioButton.setTextColor(getApplicationContext().getResources().getColor(R.color.colorPrimary));
} else {
maleRadioButton.setTextColor(getApplicationContext().getResources().getColor(R.color.lightGray));
}
}
});
,我设置<item name="android:buttonTint">@color/colorAccent</item>
,但未被选中的单选按钮是colorAccent
而不是lightGray
任何想法?
您是否尝试过在您的可绘制中实现选择器 –
使用StateList –
不能。在这种情况下,我如何使用'StateList'? – y07k2