【问题标题】:Scroll not working with Multiple GridView in a ScrollView滚动不适用于 ScrollView 中的多个 GridView
【发布时间】:2014-03-25 09:45:58
【问题描述】:

我试图在 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>

【问题讨论】:

标签: android gridview


【解决方案1】:

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

例如:android:layout_width="400dp"

【讨论】:

    【解决方案2】:
    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;
    }
    });`
    

    这里的滚动视图可以用你的gridview替换

    【讨论】:

      猜你喜欢
      • 2013-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多