开发者

Gallery inside a ScrollView - vertical scrolling doesn't work

There were some questions about ScrollViews inside Gallery etc., however I have something exactly opposite here and I can't find any solution.

The problem: I have multiple Galleries in one ScrollView. Horizontal scrolling for Galleries works fine (nothing changed here, just a standard Gallery class from SDK), but vertical scrolling for ScrollView, for whole activity does not. It looks like Galleries are intercepting touch events. Could you please help me to solve this out?

This is my layout 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
              开发者_StackOverflow  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>

Thanks!


You could make the top RelativeLayout (which contains all the other RelativeLayouts), to be about 30-40 dp smaller in width then the ScrollView. This allows the user to touch an area of the ScrollView which is not covered by a Gallery, so the Touch is not intercepted and should work as expected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜