Android中的布局滚动问题

Android中的布局滚动问题,android,android-layout,layout,scrollview,Android,Android Layout,Layout,Scrollview,我的布局滚动条有问题。下面的布局很好。我有一个水平滚动的画廊视图,下面有一个垂直滚动的列表视图滚动条。现在,当我向下滚动底部的列表视图时,gallery视图应该向上滚动,这样列表视图就可以用列表视图占据整个屏幕。当我再次向上滚动时,gallery视图应该回到顶部。有没有办法通过隐藏/显示gallery视图来处理这个问题 XML布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androi

我的布局滚动条有问题。下面的布局很好。我有一个水平滚动的画廊视图,下面有一个垂直滚动的列表视图滚动条。现在,当我向下滚动底部的列表视图时,gallery视图应该向上滚动,这样列表视图就可以用列表视图占据整个屏幕。当我再次向上滚动时,gallery视图应该回到顶部。有没有办法通过隐藏/显示gallery视图来处理这个问题

XML布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="#c6c6c6"
        android:padding="10dp" >
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            layout_alignParentLeft="true"
            android:text="Stores"
            android:textSize="20dp" />       
    </RelativeLayout>
    <Gallery
        android:id="@+id/gallery1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:gravity="left"
        android:listSelector="@color/gridviewlistselector"
        android:paddingLeft="10dp"
        android:paddingRight="20dp"
        android:paddingTop="10dp"
        android:spacing="10dp" />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="#c6c6c6"
        android:padding="10dp" >
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            layout_alignParentLeft="true"
            android:text="Products"
            android:textSize="20dp" />
    </RelativeLayout>
    <GridView
        android:id="@+id/product_grid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/texture"
        android:drawSelectorOnTop="true"
        android:horizontalSpacing="5dp"
        android:listSelector="@color/gridviewlistselector"
        android:numColumns="2"
        android:stretchMode="columnWidth"
        android:verticalSpacing="5dp" />
</LinearLayout>
</LinearLayout>

使用scrollview解决了该问题。它很好用

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:focusableInTouchMode="true" >
<LinearLayout
        android:id="@+id/store"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="#c6c6c6"
        android:padding="10dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            layout_alignParentLeft="true"
            android:text="Stores"
            android:textSize="20dp" />
    </RelativeLayout>

    <Gallery
        android:id="@+id/gallery1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:gravity="left"
        android:listSelector="@color/gridviewlistselector"
        android:paddingLeft="10dp"
        android:paddingRight="20dp"
        android:paddingTop="10dp"
        android:spacing="10dp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="#c6c6c6"
        android:padding="10dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            layout_alignParentLeft="true"
            android:text="Products"
            android:textSize="20dp" />
    </RelativeLayout>

    <GridView
        android:id="@+id/product_grid"
        android:layout_width="wrap_content"
        android:layout_height="2000dp"
        android:background="@drawable/texture"
        android:drawSelectorOnTop="true"
        android:horizontalSpacing="5dp"
        android:listSelector="@color/gridviewlistselector"
        android:numColumns="2"
        android:stretchMode="columnWidth"
        android:verticalSpacing="5dp" />
</LinearLayout>

<LinearLayout>
</LinearLayout>

</ScrollView>