android.widget.CheckBox#setButtonTintList ( )源码实例Demo

下面列出了android.widget.CheckBox#setButtonTintList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: a   文件: TintHelper.java

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);
    }
}
 
源代码2 项目: MyBookshelf   文件: TintHelper.java

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);
    }
}
 
源代码3 项目: NewsMe   文件: MDTintHelper.java

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);
    }
}
 
源代码4 项目: talk-android   文件: MDTintHelper.java

@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);
    }
}
 
源代码5 项目: APlayer   文件: TintHelper.java

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);
  }
}
 
源代码6 项目: AndroidTint   文件: EmTintUtils.java

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);
    }
}
 
源代码7 项目: PowerFileExplorer   文件: Utils.java

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);
    }
}
 
源代码8 项目: spline   文件: LayerBindingAdapters.java

/**
 * 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);
}
 
源代码9 项目: Liz   文件: ThemeHelper.java

public void themeCheckBox(CheckBox chk) {
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		chk.setButtonTintList(getTintList());
		chk.setTextColor(getTextColor());
	}
}
 

public void themeCheckBox(CheckBox chk) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    chk.setButtonTintList(getTintList());
    chk.setTextColor(getTextColor());
  }
}