将TextView与progressbar的进度对齐 [英] Align TextView with the progress of progressbar
本文介绍了将TextView与progressbar的进度对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 TextView
与水平的 ProgressBar
的进度对齐.我想在 ProgressBar
的进度位置正上方放置一个 TextView
.进度可能会更改.另外,我希望将 TextView
保留在一行中,尽管文本长度可能会更改.
How can I align a TextView
with the progress of a horizontal ProgressBar
. I want to put a TextView
right above the progress position of the ProgressBar
. The progress might be changed. Also, I want the TextView
to be kept in one line, although the text length might be changed.
推荐答案
从progressBar计算拇指的x位置并将其应用于textview
Calculate the x position of thumb from progressBar and apply it to textview
var xPosition= (((seekBar.right - seekBar.left) / seekBar.max) * seekBar.progress ) + seekBar.left
progressTextView.translationX = xPosition.toFloat() - (progressTextView.width/2)
这篇关于将TextView与progressbar的进度对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文