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

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

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

SeekBar.getThumb介绍

暂无

代码示例

代码示例来源:origin: aa112901/remusic

@Override
public Drawable getThumb() {
  if (Build.VERSION.SDK_INT >= 16) {
    return super.getThumb();
  }
  return drawable;
}

代码示例来源:origin: stackoverflow.com

public int getSeekBarThumbPosX(SeekBar seekBar) {
  int posX;
  if (Build.VERSION.SDK_INT >= 16) {
    posX = seekBar.getThumb().getBounds().centerX();
  } else {
    int left = seekBar.getLeft() + seekBar.getPaddingLeft();
    int right = seekBar.getRight() - seekBar.getPaddingRight();
    float width = (float) (seekBar.getProgress() * (right - left)) / seekBar.getMax();
    posX = Math.round(width) + seekBar.getThumbOffset();
  }
  return posX;
}

代码示例来源:origin: naman14/Timber

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View rootView = inflater.inflate(
      R.layout.fragment_timber6, container, false);
  setMusicStateListener();
  setSongDetails(rootView);
  initGestures(rootView.findViewById(R.id.album_art));
  ((SeekBar) rootView.findViewById(R.id.song_progress)).getProgressDrawable().setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY));
  ((SeekBar) rootView.findViewById(R.id.song_progress)).getThumb().setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP));
  nextSong = (TextView) rootView.findViewById(R.id.title_next);
  nextArt = (CircleImageView) rootView.findViewById(R.id.album_art_next);
  rootView.findViewById(R.id.nextView).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      MusicPlayer.next();
    }
  });
  return rootView;
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onBlocked() {
  super.onBlocked();
  controlsVisibilityHandler.removeCallbacksAndMessages(null);
  animateView(controlsRoot, false, DEFAULT_CONTROLS_DURATION);
  playbackSeekBar.setEnabled(false);
  // Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, so sets the color again
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
  loadingPanel.setBackgroundColor(Color.BLACK);
  animateView(loadingPanel, true, 0);
  animateView(surfaceForeground, true, 100);
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onPlaying() {
  super.onPlaying();
  updateStreamRelatedViews();
  showAndAnimateControl(-1, true);
  playbackSeekBar.setEnabled(true);
  // Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, so sets the color again
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
  loadingPanel.setVisibility(View.GONE);
  animateView(currentDisplaySeek, AnimationUtils.Type.SCALE_AND_ALPHA, false, 200);
}

代码示例来源:origin: TeamNewPipe/NewPipe

playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
this.playbackSeekBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);

代码示例来源:origin: dkim0419/SoundRecorder

(getResources().getColor(R.color.primary), getResources().getColor(R.color.primary));
mSeekBar.getProgressDrawable().setColorFilter(filter);
mSeekBar.getThumb().setColorFilter(filter);

代码示例来源:origin: dev-labs-bg/fullscreen-video-view

private void setupProgressBar(TypedArray a) {
  int color = a.getColor(R.styleable.VideoControllerView_progress_color, 0);
  if (color != 0) {
    // Set the default color
    progressBarColor = color;
  }
  progress.getProgressDrawable().setColorFilter(progressBarColor, PorterDuff.Mode.SRC_IN);
  progress.getThumb().setColorFilter(progressBarColor, PorterDuff.Mode.SRC_IN);
}

代码示例来源:origin: yuyangXu0222/eBook

private void setCurSeekBarStyle() {
  for (SeekBar seekBar : mSeekBars) {
    //获取seekBar的layer-list drawable对象
    LayerDrawable layerDrawable = (LayerDrawable) seekBar.getProgressDrawable();
    //层次包括背景图和进度,所以进度直接设为1,获取并设置进度条背景
    Drawable drawable = layerDrawable.getDrawable(1);
    drawable.setColorFilter(mStrokeColors[mTheme], PorterDuff.Mode.SRC);
    //获取thumb背景
    Drawable thumb = seekBar.getThumb();
    thumb.setColorFilter(mStrokeColors[mTheme], PorterDuff.Mode.SRC);
  }
}

代码示例来源:origin: rkkr/simple-keyboard

@Override
protected View onCreateDialogView() {
  final View view = super.onCreateDialogView();
  mSeekBarRed = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar_red);
  mSeekBarRed.setMax(255);
  mSeekBarRed.setOnSeekBarChangeListener(this);
  mSeekBarRed.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
  mSeekBarRed.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
  mSeekBarGreen = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar_green);
  mSeekBarGreen.setMax(255);
  mSeekBarGreen.setOnSeekBarChangeListener(this);
  mSeekBarGreen.getThumb().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
  mSeekBarGreen.getProgressDrawable().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
  mSeekBarBlue = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar_blue);
  mSeekBarBlue.setMax(255);
  mSeekBarBlue.setOnSeekBarChangeListener(this);
  mSeekBarBlue.getThumb().setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN);
  mSeekBarBlue.getProgressDrawable().setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN);
  mValueView = (TextView)view.findViewById(R.id.seek_bar_dialog_value);
  return view;
}

代码示例来源:origin: antonKozyriatskyi/CircularProgressIndicator

@Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    int redProgress = red.getProgress();
    int greenProgress = green.getProgress();
    int blueProgress = blue.getProgress();
    colorResult.setBackgroundColor(Color.rgb(redProgress, greenProgress, blueProgress));
    switch (seekBar.getId()) {
      case R.id.sb_red:
        seekBar.getProgressDrawable().setColorFilter(Color.rgb(redProgress, 0, 0), mode);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
          seekBar.getThumb().setColorFilter(Color.rgb(redProgress, 0, 0), mode);
        }
        break;
      case R.id.sb_green:
        seekBar.getProgressDrawable().setColorFilter(Color.rgb(0, greenProgress, 0), mode);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
          seekBar.getThumb().setColorFilter(Color.rgb(0, greenProgress, 0), mode);
        }
        break;
      case R.id.sb_blue:
        seekBar.getProgressDrawable().setColorFilter(Color.rgb(0, 0, blueProgress), mode);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
          seekBar.getThumb().setColorFilter(Color.rgb(0, 0, blueProgress), mode);
        }
        break;
    }
  }
};

代码示例来源:origin: antonKozyriatskyi/CircularProgressIndicator

red.getThumb().setColorFilter(Color.rgb(red.getProgress(), 0, 0), mode);
green.getThumb().setColorFilter(Color.rgb(0, green.getProgress(), 0), mode);
blue.getThumb().setColorFilter(Color.rgb(0, 0, blue.getProgress()), mode);

代码示例来源:origin: ywwynm/EverythingDone

public static void setSeekBarColor(SeekBar seekBar, int color) {
  if (DeviceUtil.hasLollipopApi()) {
    seekBar.setProgressTintList(ColorStateList.valueOf(color));
  } else {
    seekBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
  }
  seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
}

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

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setIndicator() {
  if (mTextProviderIndicator != null) {
    mTextViewProgress.setText(mTextProviderIndicator
        .provideText(getProgress()));
  } else {
    if (mIndicatorText != null) {
      try {
        mTextViewProgress.setText(String.valueOf(String.format(
            mIndicatorText, getProgress())));
      } catch (Exception e) {
        mTextViewProgress.setText(String.valueOf(getProgress()));
      }
    } else {
      mTextViewProgress.setText(String.valueOf(getProgress()));
    }
  }
  Rect padding = new Rect();
  mSeekBar.getThumb().getPadding(padding);
  int thumbPos = mSeekBar.getPaddingLeft() + mMeasuredWidth
      * mSeekBar.getProgress() / mSeekBar.getMax();
  thumbPos = (int) Math.ceil(thumbPos);
  mWrapperIndicator.setX(thumbPos
      - (int) Math.ceil(mWrapperIndicator.getWidth() / 2));
}

代码示例来源:origin: fasteque/rgb-tool

getMainActivity().setRedColor(progress);
thumbRect = seekBar.getThumb().getBounds();
getMainActivity().setGreenColor(progress);
thumbRect = seekBar.getThumb().getBounds();
getMainActivity().setBlueColor(progress);
thumbRect = seekBar.getThumb().getBounds();
getMainActivity().setOpacity(progress);
thumbRect = seekBar.getThumb().getBounds();

代码示例来源:origin: dev-labs-bg/fullscreen-video-view

if (progress != null) {
  progress.getProgressDrawable().setColorFilter(progressBarColor, PorterDuff.Mode.SRC_IN);
  progress.getThumb().setColorFilter(progressBarColor, PorterDuff.Mode.SRC_IN);
  progress.setOnSeekBarChangeListener(seekListener);
  progress.setMax(1000);

代码示例来源: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: HemendraGangwar/VideoTrimmingLikeWhatsapp

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
private void setUpMargins() {
  int marge = mRangeSeekBarView.getThumbs().get(0).getWidthBitmap();
  int widthSeek = mHolderTopView.getThumb().getMinimumWidth() / 2;
  RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mHolderTopView.getLayoutParams();
  lp.setMargins(marge - widthSeek, 0, marge - widthSeek, 0);
  mHolderTopView.setLayoutParams(lp);
  lp = (RelativeLayout.LayoutParams) mTimeLineView.getLayoutParams();
  lp.setMargins(marge, 0, marge, 0);
  mTimeLineView.setLayoutParams(lp);
  lp = (RelativeLayout.LayoutParams) mVideoProgressIndicator.getLayoutParams();
  lp.setMargins(marge, 0, marge, 0);
  mVideoProgressIndicator.setLayoutParams(lp);
}

代码示例来源: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);
  }
}

相关文章

SeekBar类方法