シークバーのツマミの位置に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のはず...