ListView sometimes uses the "item" unit (total number of items, first
visible item, etc) instead of pixels because it cannot always know the
exact pixel height of all items. You can also use units that come from your
dataset (a map could very well use meters for instance, a graph could use
time or percentage.)

Feel free to use pixels but it's not mandatory. What matters is that all 3
methods use the same unit.
On Oct 6, 2012 7:50 AM, "Raffaele Sgarro" <[email protected]> wrote:

> The documentation for computeVerticalScrollRange() 
> says<http://developer.android.com/reference/android/view/View.html#computeVerticalScrollRange()>
> :
>
>>
>> Compute the vertical range that the vertical scrollbar represents.
>> The range is expressed in *arbitrary units* that must be the same as the
>> units used by 
>> computeVerticalScrollExtent()<http://developer.android.com/reference/android/view/View.html#computeVerticalScrollExtent()>
>>  
>> andcomputeVerticalScrollOffset()<http://developer.android.com/reference/android/view/View.html#computeVerticalScrollOffset()>
>> .
>
>
> The same *arbitrary units* are mentioned in the other two methods.
> Looking at the sources, this is what I found:
>
>     protected int computeVerticalScrollRange() {
>         return getHeight();
>     }
>     protected int computeVerticalScrollOffset() {
>         return mScrollY;
>     }
>     protected int computeVerticalScrollExtent() {
>         return getHeight();
>     }
>
> So, what's going on here? getHeight() is documented to return the height
> of the view in pixels, and I wander if it makes any sense to measure things
> in miles, kilometers, astronomic units... Do they documented it in such a
> way to allow subclasses to use percentages or number of items?
>
> In particular, I looked at this methods because I'm implementing a
> ListView with a custom background<http://stackoverflow.com/q/12737600/315306>,
> and it seems I need to deal with scroll dimensions
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to