开发者

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

开发者 https://www.devze.com 2023-03-18 02:44 出处:网络
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 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 t开发者_开发技巧o a child element in the middle of a row.

Thanks.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号