Android Scrollview + GridView不滚动

时间:2014-12-10 17:31:15

标签: android gridview scroll scrollview

我有这个结构:

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

    <ScrollView
        android:id="@+id/scrollViewContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <ListView
                android:id="@+id/categories_listView"
                android:layout_width="250dp"
                android:layout_height="match_parent"
                android:background="#FFFFFF"
                android:visibility="gone">

            </ListView>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">


                <android.support.v4.view.ViewPager
                    android:id="@+id/cataloguesViewPager"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"/>

                <GridView
                    android:id="@+id/productsGridView"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:drawSelectorOnTop="true"
                    android:gravity="center"
                    android:horizontalSpacing="1dp"
                    android:numColumns="5"
                    android:stretchMode="columnWidth"
                    android:verticalSpacing="1dp">
                </GridView>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

    <ImageButton
        android:id="@+id/categories_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_margin="5dp"
        android:src="@drawable/categories_button" />

    <ImageButton
        android:id="@+id/send_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_margin="5dp"
        android:src="@drawable/send_button" />

</RelativeLayout>

在我的活动中,我禁用了GridView滚动

productsGridView = (GridView) findViewById(R.id.productsGridView);
productsGridView.setOnTouchListener(new View.OnTouchListener(){
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if(event.getAction() == MotionEvent.ACTION_MOVE){
                        return true;
                    }
                    return false;
                }
            });

我想要scrollView滚动内的所有视图,我的意思是,当我向上滚动时,应显示GridView中的所有元素,并且PagerView应该消失。< / p>

有什么想法吗? 谢谢!

0 个答案:

没有答案