简体   繁体   English

ListView - 滚动项目使其触及视图顶部?

[英]ListView - scroll an item so it touches top of view?

Possible? 可能? I know there's smoothScrollToPosition() (in api >= 8), but that doesn't make the requested element touch the top of the listview. 我知道有smoothScrollToPosition()(在api> = 8),但这并没有使请求的元素触及列表视图的顶部。 It just says that the item will be visible. 它只是说该项目是可见的。

I imagine I could measure each item somehow and set the scroll position manually, this doesn't help on my last few rows though, since those should not be allowed to scroll to the top anyway. 我想我可以以某种方式测量每个项目并手动设置滚动位置,但这对我的最后几行没有帮助,因为不管怎样都不允许滚动到顶部。

Use case - I want me users to pop open the keyboard and comment on an item in my ListView. 用例 - 我希望用户弹出键盘并对ListView中的项目进行注释。 The ime keyboard will cover some portion of the screen, so I want the 'focused' row to be touching the top of the view so they remember what they're commenting on. ime键盘将覆盖屏幕的某些部分,因此我希望“聚焦”行触摸视图的顶部,以便他们记住他们正在评论的内容。

Thanks 谢谢

I think you can add a big & empty footerView when your user open the keyboard. 我想你可以在用户打开键盘时添加一个大而空的footerView。 and remove the footerview when user close the keyboard. 用户关闭键盘时删除页脚视图。 if you add a big footerview, you can use ListView.SetSelection(last_row_pos) After that, the last row will touch top of view. 如果你添加一个大的页脚视图,你可以使用ListView.SetSelection(last_row_pos)之后,最后一行将触及视图的顶部。

I think you can use a set of flags in your manifest under your activity element which will allow you to do this. 我认为你可以在你的活动元素下的清单中使用一组标志,这将允许你这样做。 Please check the docs to see what your various options are. 请查看文档以了解您的各种选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM