简体   繁体   English

Android中的自定义搜索栏

[英]Custom Seekbar in android

I am trying to build the custom seekbar in Android.What I have done is like 我正在尝试在Android中构建自定义搜索栏。我所做的就像

Custom SeekBar 自定义SeekBar

I want is to show the progress below the seekbar like 我想要的是显示搜索栏下方的进度

Desired Image 所需的图像

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 请从下面的链接下载示例并根据需要进行修改

  1. https://github.com/dolphinwang/RangeSeekbar https://github.com/dolphinwang/RangeSeekbar
  2. https://github.com/karabaralex/android-comboseekbar https://github.com/karabaralex/android-comboseekbar
  3. https://github.com/vashisthg/StartPointSeekBar https://github.com/vashisthg/StartPointSeekBar

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM