看到一個繼承ListView的例子,裡面有兩個表達式,一個計算滾動條高度,一個計算滾動條位移,我想知道為什麼這樣計算。希望有人解答,謝謝!
滾動條高度計算:
滾動條位移計算:
滾動條高度計算:
int height = Math.round((float) getMeasuredHeight()
* computeVerticalScrollExtent()
/ computeVerticalScrollRange());
滾動條位移計算:
int thumbOffset = Math
.round((float) (getMeasuredHeight() - height)
* computeVerticalScrollOffset()
/ (computeVerticalScrollRange() - computeVerticalScrollExtent()));