I am trying to build the custom seekbar in Android.What I have done is like
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
i hope it will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.