简体   繁体   English

以编程方式滚动ListView

[英]Programmatically scroll ListView

I have an activity which consists of a ListView . 我有一个包含ListView的活动。 The problem is that the background color of the activity is the same color as the ListView (whithin that activity), what causes a lot of users to miss the fact that they are able to scroll the list. 问题在于活动的背景颜色与ListView相同(在该活动中),这导致许多用户错过他们能够滚动列表的事实。

I want to achieve an effect on which when the activity loads, I will programmatically scroll the list for a few milliseconds and scroll back, so the user will understand it is scrollable. 我想实现一种效果,当活动加载时,我将以编程方式滚动列表几毫秒并向后滚动,以便用户理解它是可滚动的。

Can it be done? 能做到吗 (API 7) (API 7)

Instead of scrolling, what about just always showing the Scrollbars? 不用滚动,仅显示滚动条怎么办?

In your XML (can't find the docs for this, but it shows up in Eclipse as a Property under "Fade scrollbars"): 在您的XML中(找不到相关文档,但它在Eclipse中显示为“渐变滚动条”下的“属性”):

android:fadeScrollbars="false"

Or if you need / want to do it programatically, you can use setScrollbarFadingEnabled() : 或者,如果您需要/想要以编程方式进行操作,则可以使用setScrollbarFadingEnabled()

yourView.setScrollbarFadingEnabled(false);

I would consider auto scrolling of the app somewhat distracting, but having the scrollbar visible is what users are accustomed to from the web. 我认为应用程序的自动滚动可能会分散注意力,但是使滚动条可见是用户习惯于从网络上进行的操作。

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

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