Почему сдвигается текст в SeekBar

Я переопределил SeekBar, потому что над ползунком thumb надо выводить техст и хотя текст меняет позицию вместе с ползунком, но по отношению к ползунку он тоже меняет позицию. Как это исправить, что я упустил?

@SuppressLint("AppCompatCustomView")
public class SuperSeekBar extends SeekBar  {
   Paint p;
   Rect rect;

    public SuperSeekBar(Context context) {
        super(context);
        p = new Paint();
    }

    public SuperSeekBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        p = new Paint();
        setOnSeekBarChangeListener(this);
    }

    public SuperSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        p = new Paint();
    }

    public SuperSeekBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        p = new Paint();
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        Log.i("tag","");
    }

    @Override
    protected void onDraw(Canvas c) {
        super.onDraw(c);
        float thumb_x = ((float)this.getProgress()/(float)this.getMax() ) *(float)this.getWidth();
        float middle = (float)this.getHeight()/2.0f;
        p.setColor(Color.BLUE);
        c.drawText("TEXT", thumb_x, middle, p );
    }
}

введите сюда описание изображения

введите сюда описание изображения


Ответы (1 шт):

Автор решения: Madoka Magica

На другой ссылке на Stackowerflow нашел ответ: https://stackoverflow.com/questions/20493577/android-seekbar-thumb-position-in-pixel

 float middle = (float)this.getHeight()/2.0f;

        float thumbPos = (float)getPaddingLeft()
                + width
                * (float) getProgress()
                / (float) getMax();
        p.setColor(Color.BLUE);
        c.drawText("TEXT", thumbPos, middle, p );
→ Ссылка