I am trying to get the position of the first visible row that is entirely visible to screen. End of scrolling, if the portion of the row is visible in first row, I need to select next position. How to do this?
Asked
Active
Viewed 5,910 times
2 Answers
2
int index = list.getFirstVisiblePosition();
View v = list.getChildAt(0);
int y = (v == null) ? 0 : v.getTop();
if (y > 0 && index + 1 < list.getCount()) {
++index;
}
Adapted from this answer.

Community
- 1
- 1

Dheeraj Vepakomma
- 26,870
- 17
- 81
- 104
-
This seems to work for me. But still I needed only the value for "y". So I didn't try the last if condition.Apart from that, the condition seems to work fine. – Andro Selva Apr 10 '12 at 08:15
0
youe need to implement OnScrollListener
on your ListView and then override the following method to get the first visible item:
@Override
public void onScroll(AbsListView view, int firstVisibleItem, final int visibleItemCount, final int totalItemCount) {
//"firstVisibleItem" is the value you need to look for
}

waqaslam
- 67,549
- 16
- 165
- 178
-
but i want to check ,whether the user can see the first row (firstVisibleItem) entirely. for example when you started scroll a list, you can see only little part in first row & last row. if you want to see entire portion of the first/bottom row, you need to scroll it up/down little future. – Jram Mar 17 '12 at 22:44
-
as long as even 1dp of an item is visible, it is considered as visible by `firstVisibleItem` – waqaslam Mar 17 '12 at 23:19