Android GridView不将所有可用空间用于不同的项目

Android GridView不将所有可用空间用于不同的项目,android,android-layout,gridview,Android,Android Layout,Gridview,我有一个指定给LinearLayout的GridView。 GridView应使用所有高度空间(匹配父项)。 但是GridView只是随着内容的增加而增加,并没有使用所有可用空间。 因此,GridView显示了一个ScrollViewer,尽管它不需要。 当GridView中项目的高度不同时,将显示ScrollViewer。 我能做什么,GridView使用全高,或者不需要时不使用ScrollViewer 在这个线性布局中,我将GridView放置为: <LinearLayout

我有一个指定给LinearLayout的GridView。 GridView应使用所有高度空间(匹配父项)。 但是GridView只是随着内容的增加而增加,并没有使用所有可用空间。 因此,GridView显示了一个ScrollViewer,尽管它不需要。 当GridView中项目的高度不同时,将显示ScrollViewer。 我能做什么,GridView使用全高,或者不需要时不使用ScrollViewer

在这个线性布局中,我将GridView放置为:

<LinearLayout
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:layout_marginLeft="20dip"
              android:layout_marginRight="20dip"
              android:layout_marginTop="30dip"
              android:id="@+id/incCon1"
              android:layout_weight="5"
          android:orientation="vertical"
             >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"

               >
    <GridView android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:id="@+id/gvContactContent1"
              android:horizontalSpacing="5dp"
              android:verticalSpacing="5dp"
              android:layout_marginTop="5dp"
            />
</LinearLayout>

这是GridView:

<LinearLayout
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:layout_marginLeft="20dip"
              android:layout_marginRight="20dip"
              android:layout_marginTop="30dip"
              android:id="@+id/incCon1"
              android:layout_weight="5"
          android:orientation="vertical"
             >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"

               >
    <GridView android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:id="@+id/gvContactContent1"
              android:horizontalSpacing="5dp"
              android:verticalSpacing="5dp"
              android:layout_marginTop="5dp"
            />
</LinearLayout>

我将带有“addView()”的GridView放在后面的LinearLayout代码中


致以最诚挚的问候

您为什么在这里使用GridView?它的功能是以多示例的列和行显示长列表,视图重用逻辑。是的,它是可滚动的。可能在这里使用GridLayout或TableLayout会更好?在那里使用GridView对我来说很有意义。例如,我需要使用columncount的动态。当GridView的高度设置为“匹配父对象”时,为什么GridView不使用整个空间