本文整理了Java中android.widget.SeekBar.getWidth()
方法的一些代码示例,展示了SeekBar.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SeekBar.getWidth()
方法的具体详情如下:
包路径:android.widget.SeekBar
类名称:SeekBar
方法名:getWidth
暂无
代码示例来源:origin: CarGuo/GSYVideoPlayer
@Override
public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromUser) {
super.onProgressChanged(seekBar, progress, fromUser);
if (fromUser && mOpenPreView) {
int width = seekBar.getWidth();
int time = progress * getDuration() / 100;
int offset = (int) (width - (getResources().getDimension(R.dimen.seek_bar_image) / 2)) / 100 * progress;
Debuger.printfError("***************** " + progress);
Debuger.printfError("***************** " + time);
showPreView(mOriginUrl, time);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mPreviewLayout.getLayoutParams();
layoutParams.leftMargin = offset;
//设置帧预览图的显示位置
mPreviewLayout.setLayoutParams(layoutParams);
if (mHadPlay && mOpenPreView) {
mPreProgress = progress;
}
}
}
代码示例来源:origin: huangfangyi/FanXin
private void doFastSeek(int seekTo) {
if (mSeekBar != null && mFastSeekBar != null) {
mSeekingIndexTxtv.setText(StringUtil.getTimeFormatString((seekTo) / 1000));
int progress = getProgressByPosition(seekTo);
mFastSeekBar.setProgress(progress);
fastSeekToTemp = seekTo;
float pivotX = (mFastSeekBar.getWidth() * mFastSeekBar.getProgress() / 1000 - mSeekingIndexTxtv.getWidth() / 2);
LayoutParams lp = (LayoutParams) mSeekIndexView.getLayoutParams();
lp.leftMargin = (int) pivotX;
mSeekIndexView.setLayoutParams(lp);
lastSeekPosition = seekTo;
}
}
代码示例来源:origin: techery/progresshint
@Override public boolean isWidgetFullyVisible(View container) {
int relativeTop = ViewUtil.getRelativeTop(mSeekBar, container);
int followPosition = getFollowPosition(getPopupStyle() == POPUP_FOLLOW ? mSeekBar.getProgress() : mSeekBar.getMax() / 2);
//
boolean fitsTop;
boolean fitsBottom;
switch (getOrientation()) {
case CW:
fitsTop =
relativeTop + followPosition + mSeekBar.getPaddingLeft() - mPopupView.getHeight() / 2 > container.getScrollY();
fitsBottom = container.getHeight() + container.getScrollY() >
relativeTop + followPosition + mSeekBar.getPaddingRight() + mPopupView.getHeight() / 2;
break;
case CCW:
fitsTop = relativeTop + (mSeekBar.getWidth() - followPosition) - mPopupView.getHeight() > container.getScrollY();
fitsBottom = container.getHeight() + container.getScrollY() + (followPosition + mSeekBar.getPaddingLeft()) >
relativeTop + mSeekBar.getWidth() + mPopupView.getHeight() / 2;
break;
default:
throw new IllegalStateException("This widget orientation is not supported");
}
//
return fitsTop && fitsBottom;
}
}
代码示例来源:origin: techery/progresshint
protected int getFollowPosition(int progress) {
return (int) (progress * (mSeekBar.getWidth() - mSeekBar.getPaddingLeft() - mSeekBar.getPaddingRight()) / (float) mSeekBar.getMax());
}
代码示例来源:origin: stackoverflow.com
mCurrentText.setText(String.valueOf(newProgress));
final int padding = mMinText.getWidth() + mSeek.getPaddingLeft();
final int totalSeekWidth = mSeek.getWidth();
final RelativeLayout.LayoutParams lp = (LayoutParams) mCurrentText
.getLayoutParams();
代码示例来源:origin: stackoverflow.com
int max = seekBar.getMax();
int available = seekBar.getWidth() - seekBar.getPaddingLeft() - seekBar.getPaddingRight();
float scale = max > 0 ? (float) seekBar.getProgress() / (float) max : 0;
if(thumbPos <= 0+thumbWidth){
thumbPos += (thumbWidth/2);
}else if(thumbPos >= seekBar.getWidth()-thumbWidth){
thumbPos -= (thumbWidth/2);
代码示例来源:origin: stackoverflow.com
int width = seekBar.getWidth() - seekBar.getPaddingLeft() - seekBar.getPaddingRight();
double progress = mProgress == 0 ? seekBar.getProgress() : mProgress;
int xPosition = (int) (seekBar.getPaddingLeft() + width * progress / seekBar.getMax());
代码示例来源: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: PangHaHa12138/Loading
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
mMeasuredWidth = mSeekBar.getWidth()
- mSeekBar.getPaddingLeft()
- mSeekBar.getPaddingRight();
mSeekBar.setPadding(
mSeekBar.getPaddingLeft(),
mSeekBar.getPaddingTop()
+ mWrapperIndicator.getHeight(),
mSeekBar.getPaddingRight(),
mSeekBar.getPaddingBottom());
setIndicator();
getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
}
});
代码示例来源:origin: bitmovin/bitcodin-android-demo
private void updateTooltipPosition() {
this.playerSeekBar.getLocationOnScreen(this.playerSeekBarPosition);
this.tooltipWrapper.setY(
this.playerSeekBarPosition[1] -
this.tooltipWrapper.getHeight() +
Utils.toPx(this.context, 17)
);
this.tooltipWrapper.setX(
this.playerSeekBarPosition[0] +
Utils.toPx(this.context, 5) +
(int) (
((float) this.playerSeekBar.getProgress() /
(float) this.playerSeekBar.getMax()) *
((float) this.playerSeekBar.getWidth() -
Utils.toPx(this.context, 10))
) - (this.tooltipWrapper.getWidth() / 2)
);
}
内容来源于网络,如有侵权,请联系作者删除!