android.widget.SeekBar#setThumbTintList ( )源码实例Demo

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

源代码1 项目: andela-crypto-app   文件: Easel.java
/**
 * Tint the {@link SeekBar}
 *
 * @param seekBar the seekbar
 * @param color   the color
 */
public static void tint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
源代码2 项目: NewsMe   文件: MDTintHelper.java
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
源代码3 项目: talk-android   文件: MDTintHelper.java
@SuppressLint("NewApi")
public static void setTint(SeekBar seekBar, int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
源代码4 项目: AndroidTint   文件: EmTintUtils.java
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
源代码5 项目: a   文件: TintHelper.java
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
    final ColorStateList s1 = getDisabledColorStateList(color,
            ContextCompat.getColor(seekBar.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else {
        Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
        seekBar.setProgressDrawable(progressDrawable);
        Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
        seekBar.setThumb(thumbDrawable);
    }
}
 
源代码6 项目: MyBookshelf   文件: TintHelper.java
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
    final ColorStateList s1 = getDisabledColorStateList(color,
            ContextCompat.getColor(seekBar.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else {
        Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
        seekBar.setProgressDrawable(progressDrawable);
        Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
        seekBar.setThumb(thumbDrawable);
    }
}
 
源代码7 项目: APlayer   文件: TintHelper.java
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
  final ColorStateList s1 = getDisabledColorStateList(color,
      ContextCompat.getColor(seekBar.getContext(),
          useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    seekBar.setThumbTintList(s1);
    seekBar.setProgressTintList(s1);
  } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
    Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
    seekBar.setProgressDrawable(progressDrawable);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
      seekBar.setThumb(thumbDrawable);
    }
  } else {
    PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
      mode = PorterDuff.Mode.MULTIPLY;
    }
    if (seekBar.getIndeterminateDrawable() != null) {
      seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
    }
    if (seekBar.getProgressDrawable() != null) {
      seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
  }
}
 
源代码8 项目: Scoops   文件: SeekBarColorAdapter.java
@Override
public void applyColor(SeekBar view, @ColorInt int color) {
    view.setIndeterminateTintList(Utils.colorToStateList(color));
    view.setThumbTintList(Utils.colorToStateList(color));
    view.setProgressTintList(Utils.colorToStateList(color));
}