[英]Custom Seekbar in android
I am trying to build the custom seekbar in Android.What I have done is like 我正在尝试在Android中构建自定义搜索栏。我所做的就像
I want is to show the progress below the seekbar like 我想要的是显示搜索栏下方的进度
Here is my code 这是我的代码
protected synchronized void onDraw(Canvas canvas) {
try {
super.onDraw(canvas);
mText = String.valueOf(getProgress());
mTextWidth = mPaint.measureText(mText);
Rect bounds = this.getProgressDrawable().getBounds();
float xImg = bounds.width() * getProgress() / getMax() + imagepaddingleft + oldPaddingLeft;
float yImg = imagepaddingtop + oldPaddingTop;
float xText = bounds.width() * getProgress() / getMax() + mImgWidth / 2 - mTextWidth / 2 + textpaddingleft + oldPaddingLeft;
float yText = yImg + textpaddingtop + mImgHei / 2 + getTextHei() / 4;
canvas.drawBitmap(bm, xImg, yImg, mPaint);
canvas.drawText(mText, xText, yText, mPaint);
} catch (Exception e) {
e.printStackTrace();
}
}
Any help will be appreciated. 任何帮助将不胜感激。
Please download samples from below link and modify according to your need 请从下面的链接下载示例并根据需要进行修改
if you want some other custom seek bar then you can goto below link: https://github.com/AnderWeb/discreteSeekBar 如果您需要其他自定义搜索栏,则可以转到以下链接: https : //github.com/AnderWeb/discreteSeekBar
i hope it will help. 我希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.