我該怎麼做?選中時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