Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to scroll ListView to a listrow's child element?

I have a ListView with quite "high" rows. The rows have quite complex layouts, and I'd like to get ListView to scroll to exactly a child element of a row. Is this possible?

I've only found .smoothScollToPosition(), but I can only specify a whole row in that. I need something more precise, to e.g. scroll to a child element in the middle of a row.

Thanks.

like image 283
Zsombor Erdődy-Nagy Avatar asked Oct 11 '22 13:10

Zsombor Erdődy-Nagy


1 Answers

Take a look at the ListView method smoothScrollToPositionFromTop (inherited from AbsListView)

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed offset pixels from the top edge of the view. If this is impossible, (e.g. the offset would scroll the first or last item beyond the boundaries of the list) it will get as close as possible. The scroll will take duration milliseconds to complete.

You'll be responsible for calculating the offset required to land in the middle of a row - that is beyond the scope of your question as it stands.

like image 78
David Snabel-Caunt Avatar answered Oct 14 '22 01:10

David Snabel-Caunt