You can use setButtonTintList (ColorStateList tint)
Applies a tint to the button drawable. Does not modify the current tint mode, which is SRC_IN by default.
Subsequent calls to setButtonDrawable(Drawable)
will automatically mutate the drawable and apply the specified tint and tint mode using setTintList(ColorStateList)
.
SAMPLE CODE
public class MainActivity extends AppCompatActivity {
RadioButton radioButton;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
radioButton = findViewById(R.id.radioButton);
ColorStateList myColorStateList = new ColorStateList(
new int[][]{
new int[]{getResources().getColor(R.color.colorPrimaryDark)}
},
new int[]{getResources().getColor(R.color.colorAccent)}
);
radioButton.setButtonTintList(myColorStateList);
}
}