是否可能&将 LinearView 和 ExpandableListView 放入 ScrollView 中是高效的
我正在制作一个包含两个不同部分的 GUI。第一部分(顶部)由一些横幅和几个固定按钮组成。所以我认为使用LinearLayout是最直接的实现方式。第二部分由几个相似的项目组合在一起组成,我认为可以使用 ExpandableListView 来实现。 但问题是内容超出了屏幕尺寸。所以我打算将其中两个放入一个ScrollView中。我检查了几个来源,似乎将“ExpandableListView”放入 ScroolView 中是不可能的,或者效率不高,所以我担心......
您能帮忙确认一下这是否可能吗?高效吗?
如果没有,您能给我一些关于这个布局设计的建议吗?
我确实期待您的支持。
真挚地。
I'm making a GUI with two different parts. The first part (at the top) is composed of some banners, several fixed buttons. So I think using LinearLayout is the most straightforward way to implement. The second part is composed of several similar items grouped together which can be implemented by using ExpandableListView, I think.
However the problem is that the content exceeds the screen size. So I intend to put two of them into a ScrollView. I checked several sources, it seems that putting "ExpandableListView" inside a ScroolView is NOT possible, or not efficent, so I'm afraid...
Would you help to confirm if this is possible? efficient ?
If no, would you give me some recommendations for this layout design?
I'm indeed looking forward to your supports.
Sincerely.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果列表顶部有固定标题,请使用 ListView 的标题视图功能。
将 ListView 放在 ScrollView 中从根本上来说是没有意义的,原因如下:
ListView 有一个目的:有效地显示无限的数据集。由于这些可能非常大(数万个项目甚至更多),因此您不希望预先为每个项目创建一个视图。相反,ListView 仅向其适配器请求当前适合屏幕上 ListView 测量空间的项目。当某个项目的视图滚动到视线之外时,ListView 会断开该视图的连接并将其交还给适配器以填充新数据并重新使用以显示其他项目。 (这是 Adapter 的
getView
方法的convertView
参数。)ScrollView 也有一个用途:获取单个子视图并为其提供“无限”的垂直空间以适应。然后,用户可以上下滚动以查看完整内容。
现在考虑到这一点,如果 ListView 有无限的高度可用于填充,那么 ListView 将为 100,000 个项目适配器创建多少个项目视图? :)
通过将 ListView 放入 ScrollView 中,您就违背了 ListView 的主要目的。父 ScrollView 将为 ListView 提供有效的无限高度以供使用,但 ListView 希望具有有限的高度,以便它可以为大型数据集提供有限的窗口。
If you have a fixed header at the top of a list, use ListView's header view feature.
Putting ListViews in ScrollViews fundamentally makes no sense and here is why:
ListView has one purpose: to efficiently display unbounded data sets. Since these can be extremely large (tens of thousands of items and more) you do not want to create a View for each item up front. Instead, ListView asks its Adapter for Views only for the items that currently fit in the ListView's measured space on screen. When an item's View is scrolled out of sight, ListView disconnects that View and hands it back to the adapter to fill out with new data and reuse to show other items. (This is the
convertView
parameter to an Adapter'sgetView
method.)ScrollView also has one purpose: to take a single child view and give it "infinite" vertical space to fit within. The user can then scroll up and down to see the full content.
Now given this, how many item Views would a ListView create for a 100,000 item Adapter if it had infinite height available to fill? :)
By putting a ListView inside a ScrollView you defeat ListView's key purpose. The parent ScrollView will give the ListView effectively infinite height to work with, but ListView wants to have a bounded height so that it can provide a limited window into a large data set.
那么可扩展列表视图本身具有可滚动属性,将其放置在滚动视图中确实是不可取的。因为这两种滚动会相互矛盾,并且在这种情况下无法获得平滑滚动。
如果我们有任何数据要在列表之前或之后显示...
最好的方法是使用页眉和页脚视图来列出...
我建议您在您的情况下使用页眉和页脚。
Well Expandable List View itself has scrollable property by placing it in scroll view is really undesirable.As the both scroll would contradict and smooth scrolling can't be obtained in that case..
If we have any data to be shown prior or later to list...
Best way is to use header and footer view to list...
I recommend you use header and footer in your case.