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

孤街浪徒 提交于 2019-12-10 13:53:27

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/6626988/is-it-possible-to-scroll-listview-to-a-listrows-child-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!