是否可以滚动的ListView到listrow的子元素?元素、ListView、listrow

由网友(失意的片刻)分享简介:我有一个相当高行一个ListView。该行具有相当复杂的布局,我想获得的ListView滚动到一排完全是一个子元素。这可能吗?我只找到.smoothScollToPosition(),但我只能在指定一整排。我需要更多的东西precise,到如滚动到一排中间一个子元素感谢。解决方案 看看ListView的方法 smoo...

我有一个相当高行一个ListView。该行具有相当复杂的布局,我想获得的ListView滚动到一排完全是一个子元素。这可能吗?

我只找到.smoothScollToPosition(),但我只能在指定一整排。我需要更多的东西precise,到如滚动到一排中间一个子元素

感谢。

解决方案

看看ListView的方法 smoothScrollToPositionFromTop (从AbsListView继承)   

平滑滚动到指定的   适配器的位置。该视图将滚动   这样,所指明的位置是   显示的偏移量的像素从顶部   视图的边缘。如果这是   不可能的,(例如,偏移量将   滚动超出了第一个或最后一个项目   列表的边界)它将   得到尽可能接近。滚动   将时间毫秒   完成了。

您会负责计算偏移所需的一排中间的土地 - 这超出了你的问题的范围,因为它的立场。

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?

Flutter 六 多子元素组件 ListView,Scaffold,AppBar,Row,Column

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.

解决方案

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.

阅读全文

相关推荐

最新文章