Let’s say I have a LinearLayout set to vertical and i’ve added 100 views to it each view is 50dp high. A user is going to scroll and fling up and down on that LinearLayout.
I need to know the index numbers of the views that are on the screen. i.e if they fling down to the middle and stop, and see 5 items on their screen, i’d need to infer 50-55.
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@id/listing_main">
</LinearLayout>
I’ve tried a bunch of ways to infer the current visible views – like taking the scrollY position and the height of my items…doesn’t seem to work out.
view.getScrollY() seems totally arbitrary compared to the other scroll mesurements
If you put them inside a list then you can use
getFirstVisiblePosition()andgetLastVisiblePosition()and use these to get all of them from first to last.http://developer.android.com/reference/android/widget/AdapterView.html