安卓smoothScrollToPosition往上顶 [英] Android smoothScrollToPosition up top

查看:798
本文介绍了安卓smoothScrollToPosition往上顶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了 smoothScrollToPosition 列表视图和它的作品完美!不过......我宁愿把它的位置在列表视图顶部,而不是仅仅在屏幕(大多是在底部,如果它需要向下滚动)。任何想法如何,我可以做到这一点?

I have set up smoothScrollToPosition on a listview and it works perfect! However... I would rather it put the position at the top of the listview rather than just on the screen (mostly on the bottom if its needed to scroll down). Any ideas how i can accomplish this?

推荐答案

使用<一个href="http://developer.android.com/reference/android/widget/AbsListView.html#smoothScrollToPositionFromTop%28int,%20int,%20int%29"相对=nofollow> smoothScrollToPositionFromTop() 。它把项目中的指定位置的像素指定数量的ListView控件(如果可能的话)的顶部。您应该简单地提供一个小胶印机。

Use smoothScrollToPositionFromTop(). It places the item at the specified position a specified number of pixels from the top of the ListView (if possible). You should simply supply a small offset.

注:需要API级别11 +

Note: requires API level 11+.

这篇关于安卓smoothScrollToPosition往上顶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆