Android的滚动型布局问题 [英] Android ScrollView layout problem

查看:164
本文介绍了Android的滚动型布局问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个列表视图中的LinearLayout。它的上市的事情一天,所以我有一个包含一个TextView星期日:后面的项目清单,其次是星期一的TextView等伟大的作品,但不适合在屏幕上。所以我加了滚动型作为的LinearLayout的父母。现在,它滚动,但列表视图都有房2项,是否有0或3项。趣谈添加滚动型父导致列表视图不大小动态。我打过电话requestLayout()上的滚动型后的名单适配器充满了他们的意见,但没有做任何事情。任何想法?

I have several ListViews in a LinearLayout. It's listing things by day, so I have a TextView containing "Sunday:" followed by a list of items, followed by a "Monday" TextView, etc. Works great, but doesn't fit in the screen. So I added a ScrollView as a parent of the LinearLayout. Now it scrolls, but the ListViews all have room for 2 entries, whether they have 0 or 3 entries. Something about adding the ScrollView parent caused the ListViews to not size dynamically. I tried calling requestLayout() on the ScrollView after the list adapters had filled their views, but that didn't do anything. Any ideas?

编辑: 从 http://www.anddev.org/viewtopic.php?p=25194 等各个环节它看来,内部的滚动型列表视图不能正确处理。任何人有一个很好的建议实施一个列表,列表?

From http://www.anddev.org/viewtopic.php?p=25194 and other links it seems that ListViews inside a ScrollView are not handled correctly. Anyone have a good suggestion for implementing a list-of-lists?

推荐答案

我很感兴趣这个话题太在,所以我做了一些研究。第一:不要把一个滚动型一个ListView(如你发现你自己)。不幸的是谷歌搜索这个问题不会导致任何的解决方案,所以我想我的建议,从我的评论以上。

I'm interested in that topic too, so I did a bit of research. First: Never put a ListView in a ScrollView (as you found out yourself). Unfortunately googling this problem doesn't lead to any solutions, so I tried my suggestion from my comment above.

我实现了自定义ListAdapter,把列表视图在一个父母的ListView。这不工作(导致相同的问题,因为与滚动型)。说起在freenode上的官方Android-IRC#Android系统开发的家伙,他们告诉我,把列表视图成一个ListView一样糟糕,甚至比将它们放入滚动型更是雪上加霜。不幸的是,他们也无法帮助我的问题。

I implemented a custom ListAdapter and put the ListViews into one parent ListView. This doesn't work (leads to the same problem as with a ScrollView). Speaking to the guys on the official android-irc #android-dev on freenode, they told me that putting ListViews into a ListView is as bad as or even worse than putting them into a ScrollView. Unfortunately they also couldn't help me with the problem.

似乎有达到你想要做什么,只有一个方法;看到这个类似的问题的答案<一href="http://stackoverflow.com/questions/306626/scrolling-with-multiple-listviews-for-android">http://stackoverflow.com/questions/306626/scrolling-with-multiple-listviews-for-android 。这样做是为了合并所有列表视图成一个单一的一个接一个的定制适配器和插入某种条目之间头。这绝对是可行的,但可能需要一些特别的努力。

There seems to be only one way to achieve what you want to do; see the answer on this similar question http://stackoverflow.com/questions/306626/scrolling-with-multiple-listviews-for-android . The idea is to merge all ListViews into a single one by a custom adapter and to insert some kind of headers between entries. This is absolutely doable but might require some special effort.

这篇关于Android的滚动型布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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