0

I have issue with my layout scroller. The layout below works fine. I have a gallery view which scrolls horizontally and below to that there is a list view scroller which scrolls vertically. Now, when I scroll down the list view at the bottom, the gallery view should scroll up so that the list view will occupy the whole screen with the list view alone. Again when I scroll up, the gallery view should come back at the top.Is there a way to handle this by hiding/showing the gallery view?

XML layout:

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

1 回答 1

0

解决了滚动视图的问题。它工作正常。

<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>
于 2012-11-29T19:17:05.670 回答