有没有办法将列表高度定义为其所有项目的高度? (安卓)
我早些时候问过这个问题,但我不太明白我得到的唯一答案。我在编写在运行时动态添加到列表的程序时遇到一些问题。该程序在列表上方有一些内容,其想法是用户向下滚动以查看程序根据用户的输入生成的列表。但是,当我使用列表时,用户不可能看到列表的下部部分,因为列表占用了一定的空间,并且如果您尝试滚动,父 ScrollView 会接管并假设您正在尝试滚动滚动整个活动。
有没有办法让列表高度动态扩展以包裹添加的子项,以便用户在使用 Scrollview 的滚动功能时可以看到列表中的所有项目?我尝试将高度设置为wrap_content,但这不起作用。任何帮助表示赞赏。谢谢。
I asked this question earlier, but I didn't really understand the only response I got. I'm having some problems writing a program that adds to a list dynamically at runtime. The program has some things above the list and the idea is that the user scrolls down to see the list that the program generates based on the user's input. However, when I use a list it is impossible for the user to see the lower parts of the list because the list takes up a set amount of space and if you try to scroll, the parent ScrollView takes over and assumes that you are trying to scroll the entire activity.
Is there a way to make the List height expand dynamically to wrap the children that are added so that the user can see all of the items in the list while using the Scrollview's scrolling ability? I have tried setting the height to wrap_content, but that did not work. Any help is appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 工程师强调,ListView 绝对不应该放在 ScrollView 中。 这个答案可能对您有一些帮助。
The Android engineers have stressed that ListViews should never be put in ScrollViews. This answer might be of some help to you.