Java Code Examples for android.widget.SeekBar#setProgressDrawable()
The following examples show how to use
android.widget.SeekBar#setProgressDrawable() .
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: DynamicPickerUtils.java From dynamic-support with Apache License 2.0 | 6 votes |
/** * Set a hue gradient progress drawable for a seek bar. * * @param seekBar The seek bar to set the hue gradient. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void setHueDrawable(@NonNull SeekBar seekBar) { if (DynamicSdkUtils.is21()) { seekBar.setProgressTintList(null); } LinearGradient gradient = new LinearGradient(0.0f, 0.0f, (float) seekBar.getWidth(), 0.0f, new int[] { 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF0000 }, null, Shader.TileMode.CLAMP); ShapeDrawable shape = new ShapeDrawable(new RectShape()); shape.getPaint().setShader(gradient); Rect bounds = seekBar.getProgressDrawable().getBounds(); bounds.inset(0, (int) (bounds.height() * 0.45f)); seekBar.setProgressDrawable(shape); seekBar.getProgressDrawable().setBounds(bounds); }
Example 2
Source File: Easel.java From andela-crypto-app with Apache License 2.0 | 6 votes |
/** * 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); } }
Example 3
Source File: MDTintHelper.java From NewsMe with Apache License 2.0 | 6 votes |
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); } }
Example 4
Source File: MDTintHelper.java From talk-android with MIT License | 6 votes |
@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); } }
Example 5
Source File: EmTintUtils.java From AndroidTint with Apache License 2.0 | 6 votes |
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); } }
Example 6
Source File: DWRulerSeekbar.java From DWRulerView with MIT License | 6 votes |
private void addCompoenet() { removeAllViews(); LineRulerView lineRulerView = new LineRulerView(context); LayoutParams rulerLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getHeight() / 3 * 2); rulerLayoutParams.addRule(ALIGN_PARENT_BOTTOM); lineRulerView.setLayoutParams(rulerLayoutParams); lineRulerView.setMinMaxValue(seekbarMinValue, seekbarMaxValue + 1); lineRulerView.setBackgroundColor(Color.DKGRAY); addView(lineRulerView); seekBar = new SeekBar(context); LayoutParams seekbarLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getHeight() / 3); seekbarLayoutParams.addRule(ALIGN_PARENT_TOP); seekBar.setLayoutParams(seekbarLayoutParams); seekBar.setBackgroundColor(Color.DKGRAY); seekBar.setProgressDrawable(null); seekBar.setPadding(0, 0, 0, 0); seekBar.setOnSeekBarChangeListener(this); seekBar.setMax(seekbarMaxValue - seekbarMinValue + 1); setSeekberThumb(seekBar, context.getResources()); addView(seekBar); }
Example 7
Source File: PasswordGenerator.java From Passbook with Apache License 2.0 | 6 votes |
private void tintSeekBar(SeekBar sb) { if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if( getContext() == null) { return; } LayerDrawable progress = (LayerDrawable)ContextCompat.getDrawable(getContext(), R.drawable.progress); if (progress == null) { return; } progress.getDrawable(0).setColorFilter(C.ThemedColors[C.colorIconNormal], PorterDuff.Mode.SRC_ATOP); progress.getDrawable(1).setColorFilter(C.ThemedColors[C.colorAccent], PorterDuff.Mode.SRC_ATOP); sb.setProgressDrawable(progress); Drawable thumb = ContextCompat.getDrawable(getContext(), R.drawable.thumb); if (thumb == null) { return; } thumb.setColorFilter(C.ThemedColors[C.colorAccent], PorterDuff.Mode.SRC_ATOP); sb.setThumb(thumb); } }
Example 8
Source File: TintHelper.java From a with GNU General Public License v3.0 | 5 votes |
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); } }
Example 9
Source File: TintHelper.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
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); } }
Example 10
Source File: PlayerActivity.java From APlayer with GNU General Public License v3.0 | 5 votes |
private void setProgressDrawable(SeekBar seekBar, int accentColor) { LayerDrawable progressDrawable = (LayerDrawable) seekBar.getProgressDrawable(); //修改progress颜色 ((GradientDrawable) progressDrawable.getDrawable(0)).setColor(getPlayerProgressColor()); (progressDrawable.getDrawable(1)).setColorFilter(accentColor, PorterDuff.Mode.SRC_IN); seekBar.setProgressDrawable(progressDrawable); }
Example 11
Source File: TintHelper.java From APlayer with GNU General Public License v3.0 | 5 votes |
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); } } }