下面列出了android.widget.SeekBar#setThumbOffset ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Initializes the views.
*
* @param rootView View that contains all the content, such as the label, gradient view, etc.
* @param textResourceId The resource ID of the text to show on the label.
* @param seekBarMax The range of the seek bar.
* @param seekBarListener The listener for when the seek bar value changes.
*/
ColorPickerAdvancedComponent(final View rootView,
final int textResourceId,
final int seekBarMax,
final OnSeekBarChangeListener seekBarListener) {
mGradientView = rootView.findViewById(R.id.gradient);
mText = (TextView) rootView.findViewById(R.id.text);
mText.setText(textResourceId);
mGradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null);
mSeekBar = (SeekBar) rootView.findViewById(R.id.seek_bar);
mSeekBar.setOnSeekBarChangeListener(seekBarListener);
mSeekBar.setMax(seekBarMax);
// Setting the thumb offset means the seek bar thumb can move all the way to each end
// of the gradient view.
Context context = rootView.getContext();
int offset = ApiCompatibilityUtils.getDrawable(context.getResources(),
R.drawable.color_picker_advanced_select_handle).getIntrinsicWidth();
mSeekBar.setThumbOffset(offset / 2);
}
/**
* Initializes the views.
*
* @param rootView View that contains all the content, such as the label, gradient view, etc.
* @param textResourceId The resource ID of the text to show on the label.
* @param seekBarMax The range of the seek bar.
* @param seekBarListener The listener for when the seek bar value changes.
*/
ColorPickerAdvancedComponent(final View rootView,
final int textResourceId,
final int seekBarMax,
final OnSeekBarChangeListener seekBarListener) {
mGradientView = rootView.findViewById(R.id.gradient);
mText = (TextView) rootView.findViewById(R.id.text);
mText.setText(textResourceId);
mGradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null);
mSeekBar = (SeekBar) rootView.findViewById(R.id.seek_bar);
mSeekBar.setOnSeekBarChangeListener(seekBarListener);
mSeekBar.setMax(seekBarMax);
// Setting the thumb offset means the seek bar thumb can move all the way to each end
// of the gradient view.
Context context = rootView.getContext();
int offset = context.getResources()
.getDrawable(R.drawable.color_picker_advanced_select_handle)
.getIntrinsicWidth();
mSeekBar.setThumbOffset(offset / 2);
}
/**
* Initializes the views.
*
* @param rootView View that contains all the content, such as the label, gradient view, etc.
* @param textResourceId The resource ID of the text to show on the label.
* @param seekBarMax The range of the seek bar.
* @param seekBarListener The listener for when the seek bar value changes.
*/
ColorPickerAdvancedComponent(final View rootView,
final int textResourceId,
final int seekBarMax,
final OnSeekBarChangeListener seekBarListener) {
mGradientView = rootView.findViewById(R.id.gradient);
mText = (TextView) rootView.findViewById(R.id.text);
mText.setText(textResourceId);
mGradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null);
mSeekBar = (SeekBar) rootView.findViewById(R.id.seek_bar);
mSeekBar.setOnSeekBarChangeListener(seekBarListener);
mSeekBar.setMax(seekBarMax);
// Setting the thumb offset means the seek bar thumb can move all the way to each end
// of the gradient view.
Context context = rootView.getContext();
int offset = context.getResources()
.getDrawable(R.drawable.color_picker_advanced_select_handle)
.getIntrinsicWidth();
mSeekBar.setThumbOffset(offset / 2);
}
private void initControllerView(View v) {
// By default these are hidden.
mPrevButton = (ImageButton) v.findViewById(PRV_BUTTON_ID);
if (mPrevButton != null) {
mPrevButton.setVisibility(View.GONE);
}
mNextButton = (ImageButton) v.findViewById(NEXT_BUTTON_ID);
if (mNextButton != null) {
mNextButton.setVisibility(View.GONE);
}
mFfwdButton = (ImageButton) v.findViewById(FFWD_BUTTON_ID);
if (mFfwdButton != null) {
mFfwdButton.setOnClickListener(mFfwdListener);
if (!mFromXml) {
mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mRewButton = (ImageButton) v.findViewById(REW_BUTTON_ID);
if (mRewButton != null) {
mRewButton.setOnClickListener(mRewListener);
if (!mFromXml) {
mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mPauseButton = (ImageButton) v.findViewById(PAUSE_BUTTON_ID);
if (mPauseButton != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
}
mProgress = (ProgressBar) v.findViewById(MEDIACONTROLLER_PROGRESS_ID);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
seeker.setOnSeekBarChangeListener(mSeekListener);
seeker.setThumbOffset(1);
}
mProgress.setMax(1000);
mProgress.setEnabled(!mDisableProgress);
}
mEndTime = (TextView) v.findViewById(END_TIME_ID);
mCurrentTime = (TextView) v.findViewById(CURRENT_TIME_ID);
}
private void initControllerView(View v) {
// By default these are hidden.
mPrevButton = (ImageButton) v.findViewById(PRV_BUTTON_ID);
if (mPrevButton != null) {
mPrevButton.setVisibility(View.GONE);
}
mNextButton = (ImageButton) v.findViewById(NEXT_BUTTON_ID);
if (mNextButton != null) {
mNextButton.setVisibility(View.GONE);
}
mFfwdButton = (ImageButton) v.findViewById(FFWD_BUTTON_ID);
if (mFfwdButton != null) {
mFfwdButton.setOnClickListener(mFfwdListener);
if (!mFromXml) {
mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mRewButton = (ImageButton) v.findViewById(REW_BUTTON_ID);
if (mRewButton != null) {
mRewButton.setOnClickListener(mRewListener);
if (!mFromXml) {
mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mPauseButton = (ImageButton) v.findViewById(PAUSE_BUTTON_ID);
if (mPauseButton != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
}
mProgress = (ProgressBar) v.findViewById(MEDIACONTROLLER_PROGRESS_ID);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
seeker.setOnSeekBarChangeListener(mSeekListener);
seeker.setThumbOffset(1);
}
mProgress.setMax(1000);
mProgress.setEnabled(!mDisableProgress);
}
mEndTime = (TextView) v.findViewById(END_TIME_ID);
mCurrentTime = (TextView) v.findViewById(CURRENT_TIME_ID);
}
private void initControllerView(View v) {
// By default these are hidden.
mPrevButton = (ImageButton) v.findViewById(PRV_BUTTON_ID);
if (mPrevButton != null) {
mPrevButton.setVisibility(View.GONE);
}
mNextButton = (ImageButton) v.findViewById(NEXT_BUTTON_ID);
if (mNextButton != null) {
mNextButton.setVisibility(View.GONE);
}
mFfwdButton = (ImageButton) v.findViewById(FFWD_BUTTON_ID);
if (mFfwdButton != null) {
mFfwdButton.setOnClickListener(mFfwdListener);
if (!mFromXml) {
mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mRewButton = (ImageButton) v.findViewById(REW_BUTTON_ID);
if (mRewButton != null) {
mRewButton.setOnClickListener(mRewListener);
if (!mFromXml) {
mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mPauseButton = (ImageButton) v.findViewById(PAUSE_BUTTON_ID);
if (mPauseButton != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
}
mProgress = (ProgressBar) v.findViewById(MEDIACONTROLLER_PROGRESS_ID);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
seeker.setOnSeekBarChangeListener(mSeekListener);
seeker.setThumbOffset(1);
}
mProgress.setMax(1000);
mProgress.setEnabled(!mDisableProgress);
}
mEndTime = (TextView) v.findViewById(END_TIME_ID);
mCurrentTime = (TextView) v.findViewById(CURRENT_TIME_ID);
}
private void initControllerView(View v) {
// By default these are hidden.
mPrevButton = (ImageButton) v.findViewById(PRV_BUTTON_ID);
if (mPrevButton != null) {
mPrevButton.setVisibility(View.GONE);
}
mNextButton = (ImageButton) v.findViewById(NEXT_BUTTON_ID);
if (mNextButton != null) {
mNextButton.setVisibility(View.GONE);
}
mFfwdButton = (ImageButton) v.findViewById(FFWD_BUTTON_ID);
if (mFfwdButton != null) {
mFfwdButton.setOnClickListener(mFfwdListener);
if (!mFromXml) {
mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mRewButton = (ImageButton) v.findViewById(REW_BUTTON_ID);
if (mRewButton != null) {
mRewButton.setOnClickListener(mRewListener);
if (!mFromXml) {
mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mPauseButton = (ImageButton) v.findViewById(PAUSE_BUTTON_ID);
if (mPauseButton != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
}
mProgress = (ProgressBar) v.findViewById(MEDIACONTROLLER_PROGRESS_ID);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
seeker.setOnSeekBarChangeListener(mSeekListener);
seeker.setThumbOffset(1);
}
mProgress.setMax(1000);
mProgress.setEnabled(!mDisableProgress);
}
mEndTime = (TextView) v.findViewById(END_TIME_ID);
mCurrentTime = (TextView) v.findViewById(CURRENT_TIME_ID);
}
private void initControllerView(View v) {
// By default these are hidden.
mPrevButton = (ImageButton) v.findViewById(PRV_BUTTON_ID);
if (mPrevButton != null) {
mPrevButton.setVisibility(View.GONE);
}
mNextButton = (ImageButton) v.findViewById(NEXT_BUTTON_ID);
if (mNextButton != null) {
mNextButton.setVisibility(View.GONE);
}
mFfwdButton = (ImageButton) v.findViewById(FFWD_BUTTON_ID);
if (mFfwdButton != null) {
mFfwdButton.setOnClickListener(mFfwdListener);
if (!mFromXml) {
mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mRewButton = (ImageButton) v.findViewById(REW_BUTTON_ID);
if (mRewButton != null) {
mRewButton.setOnClickListener(mRewListener);
if (!mFromXml) {
mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
}
}
mPauseButton = (ImageButton) v.findViewById(PAUSE_BUTTON_ID);
if (mPauseButton != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
}
mProgress = (ProgressBar) v.findViewById(MEDIACONTROLLER_PROGRESS_ID);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
seeker.setOnSeekBarChangeListener(mSeekListener);
seeker.setThumbOffset(1);
}
mProgress.setMax(1000);
mProgress.setEnabled(!mDisableProgress);
}
mEndTime = (TextView) v.findViewById(END_TIME_ID);
mCurrentTime = (TextView) v.findViewById(CURRENT_TIME_ID);
}