vendredi 16 septembre 2016

RadioButton color and text color change when selected

How can I do this?

enter image description here

This is what I use to change text color:

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));
                }
            }
        });

and I set <item name="android:buttonTint">@color/colorAccent</item>, but the unselected radio button is colorAccent instead of lightGray

Any ideas?




Aucun commentaire:

Enregistrer un commentaire