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

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

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

SeekBar.setThumb介绍

暂无

代码示例

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

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

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

@Override
public void setThumb(Drawable thumb) {
  Rect localRect = null;
  if (drawable != null) {
    localRect = drawable.getBounds();
  }
  super.setThumb(drawable);
  drawable = thumb;
  if ((localRect != null) && (drawable != null)) {
    drawable.setBounds(localRect);
  }
}

代码示例来源: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: 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: 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: stackoverflow.com

seekBar.setThumb(thumb);
seekBar.setProgress(1);
seekBar.setVisibility(View.VISIBLE);

代码示例来源:origin: gumingwei/WellSwipe

/***
 * Called to substitute getThumb() for APIs below 16
 *
 * @param thumb
 */
@Override
public void setThumb(final Drawable thumb) {
  super.setThumb(thumb);
  mThumb = thumb;
}

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

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.SeekBar;

public class MainActivity extends Activity {
  private SeekBar seekBar1;

  private SeekBar seekBar2;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
     seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
     seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
     seekBar1.setProgress(15);
     seekBar2.setProgress(55);
     Drawable ii = getResources().getDrawable(R.drawable.ii);
    // Drawable iii = getResources().getDrawable(R.drawable.ii);
     seekBar1.setThumb(ii);
     seekBar2.setThumb(ii);

  }


}

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

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.SeekBar;

public class MainActivity extends Activity {
  private SeekBar seekBar1;

  private SeekBar seekBar2;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
     seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
     seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
     seekBar1.setProgress(15);
     seekBar2.setProgress(55);
     Drawable ii = getResources().getDrawable(R.drawable.ii);
     Drawable iii = getResources().getDrawable(R.drawable.ii);
     seekBar1.setThumb(ii);
     seekBar2.setThumb(iii);

  }


}

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

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.SeekBar;

public class MainActivity extends Activity {
  private SeekBar seekBar1;

  private SeekBar seekBar2;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
     seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
     seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
     seekBar1.setProgress(15);
     seekBar2.setProgress(55);
     Drawable ii = getResources().getDrawable(R.drawable.ii);
    // Drawable iii = getResources().getDrawable(R.drawable.ii);
     seekBar1.setThumb(ii);
     seekBar2.setThumb(ii);

  }


}

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

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.SeekBar;

public class MainActivity extends Activity {
  private SeekBar seekBar1;

  private SeekBar seekBar2;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
     seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
     seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
     seekBar1.setProgress(15);
     seekBar2.setProgress(55);
     Drawable ii = getResources().getDrawable(R.drawable.ii);
     Drawable iii = getResources().getDrawable(R.drawable.ii);
     seekBar1.setThumb(ii);
     seekBar2.setThumb(iii);

  }
}

代码示例来源:origin: geniusgithub/AndroidDialer

@Override
public void resetSeekBar() {
  mPlaybackSeek.setProgress(0);
  mPlaybackSeek.setEnabled(false);
  mPlaybackSeek.setThumb(mVoicemailSeekHandleDisabled);
}

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

@Override
  public boolean onPreDraw() {
    if (seekBar.getHeight() > 0) {
      Drawable thumb = res.getDrawable(R.drawable.indicator);
      int h = seekBar.getMeasuredHeight();
      int w = h;
      Bitmap bmpOrg = ((BitmapDrawable) thumb).getBitmap();
      Bitmap bmpScaled = Bitmap.createScaledBitmap(bmpOrg, w, h, true);
      Drawable newThumb = new BitmapDrawable(res, bmpScaled);
      newThumb.setBounds(0, 0, newThumb.getIntrinsicWidth(), newThumb.getIntrinsicHeight());
      seekBar.setThumb(newThumb);
      seekBar.getViewTreeObserver().removeOnPreDrawListener(this);
    }
    return true;
  }
});

代码示例来源:origin: geniusgithub/AndroidDialer

@Override
public void enableUiElements() {
  mDeleteButton.setEnabled(true);
  mStartStopButton.setEnabled(true);
  mPlaybackSeek.setEnabled(true);
  mPlaybackSeek.setThumb(mVoicemailSeekHandleEnabled);
}

代码示例来源:origin: wutongke/AndroidSkinAnimator

@Override
  public void applySkin() {
    super.applySkin();
    mThumbResId = checkResourceId(mThumbResId);
    if (mThumbResId != INVALID_ID) {
      mView.setThumb(SkinCompatResources.getInstance().getDrawable(mThumbResId));
    }
  }
}

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

TableRow tr = new TableRow(this);
   tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
   /* Create a SeekBar to be the row-content. */
  SeekBar seekBar = new SeekBar(this);
     seekBar.setMax(15);
 //      seekBar.setIndeterminate(true);
     ShapeDrawable thumb = new ShapeDrawable(new OvalShape());
     thumb.setIntrinsicHeight(80);
     thumb.setIntrinsicWidth(30);
     seekBar.setThumb(thumb);
     seekBar.setProgress(1);
     seekBar.setVisibility(View.VISIBLE);
     seekBar.setBackgroundColor(Color.BLUE);
     LayoutParams lp = new LayoutParams(200, 50);
     seekBar.setLayoutParams(lp); 
 seekBar.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));

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

/**
 * Updates current thumb to the specified one. If this seek bar has discrete mode enabled
 * ({@link #isDiscrete()}), the given thumb will be updated to scaleable drawable if it is not yet.
 *
 * @param thumb The new thumb to update to.
 */
private void updateThumb(Drawable thumb) {
  this.ensureDecorator();
  if (mDecorator.hasPrivateFlag(PFLAG_DISCRETE)) {
    thumb = mAnimations.makeThumbScaleable(thumb, Gravity.CENTER);
  }
  if (mThumb != thumb) {
    super.setThumb(mThumb = thumb);
    this.applyThumbTint();
  }
}

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

/**
 * Updates current thumb to the specified one. If this seek bar has discrete mode enabled
 * ({@link #isDiscrete()}), the given thumb will be updated to scaleable drawable if it is not yet.
 *
 * @param thumb The new thumb to update to.
 */
private void updateThumb(Drawable thumb) {
  this.ensureDecorator();
  if (mDecorator.hasPrivateFlag(PFLAG_DISCRETE)) {
    thumb = mAnimations.makeThumbScaleable(thumb, Gravity.CENTER);
  }
  if (mThumb != thumb) {
    super.setThumb(mThumb = thumb);
    this.applyThumbTint();
  }
}

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

));
seekBar.setThumb(bd);

相关文章

SeekBar类方法