滚动不在ScrollView中使用Multiple GridView

时间:2014-03-25 09:45:58

标签: android gridview

我试图在LinearLayout和ScrollView中显示多个GridView,但如果第一个滚动视图的内容更多,则第一个GridView填充屏幕并且滚动不起作用。这是我目前的布局

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/FrameLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ScrollView
        android:id="@+id/scrollview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/owngroup_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/own_groups"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <GridView
                android:id="@+id/GridView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </GridView>

            <TextView
                android:id="@+id/ingroup_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/in_groups"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <GridView
                android:id="@+id/inGroups"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </GridView>
        </LinearLayout>
    </ScrollView>

</FrameLayout>

2 个答案:

答案 0 :(得分:0)

更改GridView的android:layout_width="match_parent"并测试值。 使用LinearLayout进行Smae动作。

示例:android:layout_width="400dp"

答案 1 :(得分:0)

parentScrollView.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event)
{
    findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event)
{

// Disallow the touch request for parent scroll on touch of
// child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});`

此处chield scroll view可以替换为gridview