unable to get right position of texBox in Thumb of seekbar

牧云@^-^@ 提交于 2019-12-11 19:46:08

问题


I am working in android. I am designing a seekbar. I added thumb there. It is showing at right place.

But at that thumb I want to show progress in text box. For this I am using this code:

int xPos = ((seekbar.getRight() - seekbar.getLeft()) * seekbar.getProgress()) /
            seekbar.getMax();

But this x coordinate is not exact. It is a little bit different.

Please suggest me what should I do for this.


回答1:


You've calculated the distance along the seekbar, so you just need to add seekbar.getLeft() onto it:

int xPos = (((seekbar.getRight() - seekbar.getLeft()) * seekbar.getProgress()) /
            seekbar.getMax()) + seekbar.getLeft();


来源:https://stackoverflow.com/questions/9175677/unable-to-get-right-position-of-texbox-in-thumb-of-seekbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!