Android 嵌入包含gridview的dialogfragment将导致只显示它的不可滚动gridview';第一排

Android 嵌入包含gridview的dialogfragment将导致只显示它的不可滚动gridview';第一排,android,gridview,android-dialogfragment,viewstub,Android,Gridview,Android Dialogfragment,Viewstub,我有一个对话框片段,其中包含一个网格视图。将其显示为对话框将按预期工作。现在,我尝试将相同的对话框片段嵌入到活动中。为此,我在活动布局中有一个视图存根,定义如下: <RelativeLayout> <!-- Other children --> <ViewStub android:id="@+id/view_stub" android:layout_below="@id/tv_content" android

我有一个
对话框片段
,其中包含一个
网格视图
。将其显示为对话框将按预期工作。现在,我尝试将相同的
对话框片段
嵌入到
活动
中。为此,我在
活动
布局中有一个
视图存根
,定义如下:

<RelativeLayout>
<!-- Other children -->

    <ViewStub
        android:id="@+id/view_stub"
        android:layout_below="@id/tv_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inflatedId="@+id/attachment"
        android:layout_centerHorizontal="true"/>

</RelativeLayout>
在检查是否有适当的
意图
附加内容后,我将上述布局充气,并使用以下代码添加
对话框片段

viewStub.setLayoutResource( R.layout.dialog_fragment_placeholder );
flPlaceHolder = ( FrameLayout ) viewStub.inflate();
getSupportFragmentManager().beginTransaction()
        .add( flPlaceHolder.getId(),
                DialogFragment.newInstance( //arguments ),
                DialogFragment.TAG )
        .commit();
这将导致添加
对话框片段
,但
网格视图
仅显示第一行,不可滚动。如果需要,这里是
对话框片段的布局

<GridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="100dp"
    android:numColumns="auto_fit"
    android:gravity="center"
    android:background="#cc000000"
    android:listSelector="@android:color/transparent">

</GridView>

我很确定这个问题是因为其中一个布局中的
layout\u height
/
layout\u width
属性不正确,但我尝试在所有可能的文件中使用所有可能的值,但没有得到任何好的结果。有什么帮助吗

<GridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="100dp"
    android:numColumns="auto_fit"
    android:gravity="center"
    android:background="#cc000000"
    android:listSelector="@android:color/transparent">

</GridView>