问题
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