Java Code Examples for android.widget.CheckBox#setButtonTintList()
The following examples show how to use
android.widget.CheckBox#setButtonTintList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TintHelper.java From a with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light), ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = createTintedDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl); box.setButtonDrawable(drawable); } }
Example 2
Source File: TintHelper.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light), ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = createTintedDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl); box.setButtonDrawable(drawable); } }
Example 3
Source File: MDTintHelper.java From NewsMe with Apache License 2.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ ThemeHelper.resolveColor(box.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 4
Source File: MDTintHelper.java From talk-android with MIT License | 6 votes |
@SuppressLint("NewApi") public static void setTint(CheckBox box, int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 5
Source File: TintHelper.java From APlayer with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light), ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = createTintedDrawable( ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl); box.setButtonDrawable(drawable); } }
Example 6
Source File: EmTintUtils.java From AndroidTint with Apache License 2.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ ThemeHelper.resolveColor(box.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 7
Source File: Utils.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public static void setTint(Context context, CheckBox box, int color) { if (Build.VERSION.SDK_INT >= 21) return; ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{getColor(context, R.color.grey), color}); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 8
Source File: LayerBindingAdapters.java From spline with Apache License 2.0 | 5 votes |
/** * Binding adapter for converting a color resource ID to a color int that can be set as the * tint of the passed CheckBox * @param view * @param resId */ @BindingAdapter("android:buttonTint") public static void setButtonTint(CheckBox view, int resId) { int tintColor = view.getContext().getColor(resId); ColorStateList colorStateList = new ColorStateList( new int[][]{new int[]{}}, new int[]{ tintColor } ); view.setButtonTintList(colorStateList); }
Example 9
Source File: ThemeHelper.java From Liz with GNU General Public License v3.0 | 4 votes |
public void themeCheckBox(CheckBox chk) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { chk.setButtonTintList(getTintList()); chk.setTextColor(getTextColor()); } }
Example 10
Source File: ThemeHelper.java From Android-AudioRecorder-App with Apache License 2.0 | 4 votes |
public void themeCheckBox(CheckBox chk) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { chk.setButtonTintList(getTintList()); chk.setTextColor(getTextColor()); } }