滚动问题,以滚动型内一个ListView [英] Scrolling issues with a ListView inside a ScrollView

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

问题描述

下面的情景概念(不含linearlayouts)

Here's the scenario conceptually (excluding linearlayouts)

ScrollView
  Button
  Checkboxes
  Spinner
  ListView (full-size, non-scrolling)
AdMob advert

即。滚动窗格,其具有在顶部,随后的结果的滤波的UI,但是广告必须始终保持可见,和向下滚动时,过滤器的UI必须滚动而去,留下最大空间的效果。

i.e. a scrolling pane, which has a filtering UI at the top, followed by results, but the advert must always remain visible, and when scrolling down the filter UI must scroll away, leaving maximum space for results.

我知道有问题了滚动型内一个ListView,但对我来说这是在许多方面的工作好(我固定的ListView的长度来阻止它崩溃)。所以屏幕滚动好听,广告原地踏步的底部,它看起来不错。

I'm aware there are issues with a ListView inside a ScrollView, though for me it is working well in many ways (I'm fixing the length of the ListView to stop it collapsing). So the screen scrolls nicely, the ad stays put at the bottom, and it looks good.

但我看到的问题是,莫名其妙地,活动开启时,滚动型滚动下来了一点,所以在ListView是在屏幕的顶部。我想这是一个默认的行为,所以我开始试图将滚动型的滚动位置强制顶端,但我已经试过各种方法,并没有看到效果:

But the problem I'm seeing is, inexplicably, when the activity opens, the ScrollView is scrolled down a bit, so the ListView is at the top of the screen. I assume this is a default behaviour, so I set about trying to force the scroll position of the ScrollView to the top, but I've tried various methods, and see no effect:

scrollview.scrollTo(0, 1000/-1000);
scrollview.smoothScrollBy(0, 1000/-1000);
scrollview.fullScroll(View.FOCUS_UP);

有没有什么办法来迫使滚动型开始与顶部的滚动位置?

Is there any way to force the ScrollView to start with the scroll position at the top?

如果不是这样,我怎么能有一个广告,不滚动断底,但始终滚动顶掉一个过滤器的用户界面?使用的ListView似乎矫枉过正,因为我并不需要滚动,但它确实提供了很多好处,以便将是很好的避免从头开始和渲染都要亲力亲为。

If not, how can I have an ad that doesn't scroll off the bottom, but a filter UI that always scrolls off the top? Using ListView seems overkill as I don't need scrolling but it does provide many benefits so would be nice to avoid starting from scratch and rendering everything myself.

推荐答案

你为什么要使用一个ListView如果你不滚动?为什么你就不能使用的LinearLayout或更适合这种情况呢?你提到的过滤器,你可以很容易地推出自己的过滤器尤其是因为显然你只是在你的列表视图的几个项目。

Why are you using a listview if you're not scrolling? Why can't you just use a linearlayout or something more fit to this situation? You mention a filter, you could very easily roll your own filter especially since apparently you just have a few items in your listview.

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

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