android.widget.SeekBar.setProgressDrawable()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中android.widget.SeekBar.setProgressDrawable()方法的一些代码示例,展示了SeekBar.setProgressDrawable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SeekBar.setProgressDrawable()方法的具体详情如下:
包路径:android.widget.SeekBar
类名称:SeekBar
方法名:setProgressDrawable

SeekBar.setProgressDrawable介绍

暂无

代码示例

代码示例来源:origin: CarGuo/GSYVideoPlayer

/**
 * 底部进度条-弹出的
 */
public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb) {
  mBottomShowProgressDrawable = drawable;
  mBottomShowProgressThumbDrawable = thumb;
  if (mProgressBar != null) {
    mProgressBar.setProgressDrawable(drawable);
    mProgressBar.setThumb(thumb);
  }
}

代码示例来源:origin: CarGuo/GSYVideoPlayer

@Override
protected void init(Context context) {
  super.init(context);
  //增加自定义ui
  if (mBottomProgressDrawable != null) {
    mBottomProgressBar.setProgressDrawable(mBottomProgressDrawable);
  }
  if (mBottomShowProgressDrawable != null) {
    mProgressBar.setProgressDrawable(mBottomProgressDrawable);
  }
  if (mBottomShowProgressThumbDrawable != null) {
    mProgressBar.setThumb(mBottomShowProgressThumbDrawable);
  }
}

代码示例来源:origin: com.albedinsky.android/ui

/**
 */
@Override
public void setProgressDrawable(Drawable drawable) {
  super.setProgressDrawable(mProgressDrawable = drawable);
  this.applyProgressTints();
}

代码示例来源:origin: com.albedinsky.android/ui-widget-picker

/**
 */
@Override
public void setProgressDrawable(Drawable drawable) {
  super.setProgressDrawable(mProgressDrawable = drawable);
  this.applyProgressTints();
}

代码示例来源:origin: Reone/Mrthumb

@Override
public void customAttr(TypedArray typedArray) {
  float textSize = typedArray.getInteger(R.styleable.VideoSeekBar_vsb_text_size, -1);
  if (textSize != -1) {
    seekTime.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
    sumTime.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
  }
  int progressHeight = (int) typedArray.getDimension(R.styleable.VideoSeekBar_vsb_seek_bar_progress_height,-1);
  if(progressHeight != -1){
    try {
      Class<?> superclass = seekbar.getClass().getSuperclass().getSuperclass();
      Field mMaxHeight = superclass.getDeclaredField("mMaxHeight");
      Field mMinHeight = superclass.getDeclaredField("mMinHeight");
      mMaxHeight.setAccessible(true);
      mMinHeight.setAccessible(true);
      mMaxHeight.set(seekbar,progressHeight);
      mMinHeight.set(seekbar,progressHeight);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  Drawable style = typedArray.getDrawable(R.styleable.VideoSeekBar_vsb_seek_bar_style);
  if (style != null) {
    seekbar.setProgressDrawable(style);
  }
}

代码示例来源:origin: adolfAn/FBReader_AS

@Override
protected void onBindDialogView(View view) {
  mySlider = (SeekBar)view.findViewById(R.id.animation_speed_slider);
  mySlider.setMax(myOption.MaxValue - myOption.MinValue);
  mySlider.setProgress(myOption.getValue() - myOption.MinValue);
  mySlider.setProgressDrawable(new SeekBarDrawable());
  super.onBindDialogView(view);
}

代码示例来源:origin: qiushi123/VideoDemoQcl

private void setSkin(Skin skin) {
    Resources resource = getContext().getResources();
    if (skin.titleColor != 0) {
      ColorStateList titleCsl = resource.getColorStateList(skin.titleColor);
      if (titleCsl != null) {
        tvTitle.setTextColor(titleCsl);
      }
    }
    if (skin.timeColor != 0) {
      ColorStateList timeCsl = resource.getColorStateList(skin.timeColor);
      if (timeCsl != null) {
        tvTimeCurrent.setTextColor(timeCsl);
        tvTimeTotal.setTextColor(timeCsl);
      }
    }
    if (skin.seekDrawable != 0) {
      Drawable bg = resource.getDrawable(skin.seekDrawable);
      Rect bounds = skProgress.getProgressDrawable().getBounds();
      skProgress.setProgressDrawable(bg);
      skProgress.getProgressDrawable().setBounds(bounds);
      pbBottom.setProgressDrawable(resource.getDrawable(skin.seekDrawable));
    }
    if (skin.bottomControlBackground != 0) {
      llBottomControl.setBackgroundColor(resource.getColor(skin.bottomControlBackground));
    }
    this.enlargRecId = skin.enlargRecId;
    this.shrinkRecId = skin.shrinkRecId;
  }
}

代码示例来源:origin: PangHaHa12138/Loading

mSeekBar.setProgressDrawable(getResources().getDrawable(
      seekBarProgressDrawableId));
else
  mSeekBar.setProgressDrawable(getResources().getDrawable(
      seekBarProgressDrawableId, null));

代码示例来源:origin: pranavpandey/dynamic-support

/**
   * 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 (DynamicVersionUtils.isLollipop()) {
      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);
  }
}

代码示例来源:origin: dwfox/DWRulerView

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);
}

代码示例来源:origin: garretyoder/app-theme-engine

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);
  }
}

代码示例来源:origin: xuancao/DynamicSkin

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_disabled_seekbar_dark : R.color.ate_disabled_seekbar_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 = 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);
  }
}

代码示例来源:origin: h4h13/RetroMusicPlayer

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);
  }
}

代码示例来源:origin: com.albedinsky.android/ui-widget-picker

mProgressDrawable.setState(getDrawableState());
super.setProgressDrawable(mProgressDrawable);
tintDrawable.attachCallback();
tintDrawable.setLevel((int) (getProgress() / (float) getMax() * MAX_LEVEL));
this.mProgressDrawable = tintDrawable;
this.applySimpleProgressTint();
super.setProgressDrawable(mProgressDrawable);
tintDrawable.attachCallback();
tintDrawable.setLevel((int) (getProgress() / (float) getMax() * MAX_LEVEL));

代码示例来源:origin: com.albedinsky.android/ui

mProgressDrawable.setState(getDrawableState());
super.setProgressDrawable(mProgressDrawable);
tintDrawable.attachCallback();
tintDrawable.setLevel((int) (getProgress() / (float) getMax() * MAX_LEVEL));
this.mProgressDrawable = tintDrawable;
this.applySimpleProgressTint();
super.setProgressDrawable(mProgressDrawable);
tintDrawable.attachCallback();
tintDrawable.setLevel((int) (getProgress() / (float) getMax() * MAX_LEVEL));

相关文章

SeekBar类方法