List of usage examples for android.widget RadioButton setButtonTintList
public void setButtonTintList(@Nullable ColorStateList tint)
From source file:com.github.dfa.diaspora_android.ui.theme.ThemeHelper.java
public static void updateRadioGroupColor(RadioGroup radioGroup) { if (radioGroup != null && Build.VERSION.SDK_INT >= 21) { for (int i = 0; i < radioGroup.getChildCount(); ++i) { RadioButton btn = ((RadioButton) radioGroup.getChildAt(i)); btn.setButtonTintList(new ColorStateList( new int[][] { new int[] { -android.R.attr.state_enabled }, new int[] { android.R.attr.state_enabled } }, new int[] { Color.BLACK, ThemeHelper.getAccentColor() })); btn.invalidate();//from w w w . jav a 2 s .c o m } } }
From source file:com.fa.mastodon.fragment.ComposeOptionsFragment.java
private static void setRadioButtonDrawable(Context context, RadioButton button, @DrawableRes int id) { ColorStateList list = new ColorStateList( new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { ThemeUtils.getColor(context, R.attr.compose_image_button_tint), ThemeUtils.getColor(context, R.attr.colorAccent) }); Drawable drawable = VectorDrawableCompat.create(context.getResources(), id, context.getTheme()); if (drawable == null) { return;/*from w ww.j a va 2 s . c o m*/ } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { button.setButtonTintList(list); } else { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTintList(drawable, list); } button.setButtonDrawable(drawable); }