【问题标题】:Gallery inside a ScrollView - vertical scrolling doesn't workScrollView 内的画廊 - 垂直滚动不起作用
【发布时间】:2011-09-20 18:44:58
【问题描述】:

有一些关于 Gallery 等中的 ScrollViews 的问题,但是我这里有一些完全相反的东西,我找不到任何解决方案。

问题:我在一个 ScrollView 中有多个画廊。画廊的水平滚动工作正常(这里没有改变,只是来自 SDK 的标准画廊类),但 ScrollView 的垂直滚动,对于整个活动没有。看起来画廊正在拦截触摸事件。你能帮我解决这个问题吗?

这是我的布局 xml:

    <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollview_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
    <RelativeLayout
        android:id="@+id/layout_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RelativeLayout
            ...>
            <Button
                .../>
            <Gallery
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/gallery_..."
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                ... />
            <TextView
                ... />
        </RelativeLayout>//this layout is repeated few times, because I have multiple galleries
    </RelativeLayout>
</ScrollView>

谢谢!

【问题讨论】:

  • 你不能可靠地将可滚动的东西放在其他可滚动的东西中。
  • 即使父母是垂直的,孩子是水平的?
  • 同样,问题是可靠。是的,有时将一个方向滚动的东西放在另一个方向滚动的东西里面是可行的。将两个在同一方向滚动的东西几乎不起作用。

标签: android android-layout android-gallery android-scrollview


【解决方案1】:

您可以使顶部的RelativeLayout(包含所有其他RelativeLayouts)的宽度比ScrollView 小大约30-40 dp。这允许用户触摸 ScrollView 中未被 Gallery 覆盖的区域,因此 Touch 不会被拦截并且应该按预期工作。

【讨论】:

    猜你喜欢
    • 2012-09-22
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 2012-06-21
    相关资源
    最近更新 更多