如何在 Android 上禁用 ListView 的滚动?
我有以下问题:我有一个包含 ListView 的困难布局。我需要禁用 ListView 的滚动功能,因为它的容器(根布局)已经有 ScrollView,并且我不需要 ListView 的滚动。我通过 android:scrollbars="none" 禁用滚动,但滚动功能将保留。我需要如果 ListView 有 10 个项目,则所有项目都将显示。我该怎么做呢?
I have the following question: I have a difficult layout that contain ListView. I need disable scrolling ability for ListView, because it's container (root Layout) have had ScrollView already, and I don't need a scrolls for ListView. I disable scrolls by android:scrollbars="none", but abilitity for scrolling would stay. I need that if ListView has 10 items that all items will be shown. How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
难道不能只使用具有 10 个元素的
LinearLayout
而不是ListView
吗?在另一个ScrollView
中拥有一个ScrollView
并不是一个好主意。Can't you just use a
LinearLayout
with 10 elements instead of theListView
? It is not a good idea to have aScrollView
in anotherScrollView
.为什么还用ListView呢?为项目创建您自己的布局并加载多次(
LayoutInflater
、.addView(listItem)
)。Why do you still use the ListView? Create your own Layout for an item and load it several times (
LayoutInflater
,.addView(listItem)
).