0
0

More than 5 years have passed since last update.

シークバーのツマミのX座標の計算

Posted at

シークバーのツマミの位置にViewを重ねて表示する機会があったので、備忘録としその際に使用したツマミの位置のX座標の計算方法を記載しようと思います。

シークバーのツマミのX座標をピクセルで取得

public float getThumbPositionX(SeekBar seekBar) {
    float width = seekBar.getWidth()
            - seekBar.getPaddingLeft()
            - seekBar.getPaddingRight()
            - seekBar.getThumb().getIntrinsicWidth();

    float thumbPositionX = width
            * (float) seekBar.getProgress()
            / (float) seekBar.getMax()
            + (float) seekBar.getPaddingLeft();

    return thumbPositionX
}

これでOKのはず...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0