1

在 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>

谢谢!

4

1 回答 1

1

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

于 2011-09-20T10:44:58.877 回答