是否可以创建具有不同大小子节点的GridView?

Ami*_*far 7 android

那么让我们试着解释一下我想做什么......

我的设计看起来像这样 -

![替代文字] [1]

为此,我创建了两个GridView,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

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

        <TextView style="@style/GroupName"
                  android:text="@string/currency_badges"/>

        <GridView android:id="@+id/currency_grid"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:columnWidth="90dp"
                  android:numColumns="auto_fit"
                  android:verticalSpacing="10dp"
                  android:horizontalSpacing="10dp"
                  android:stretchMode="columnWidth"
                  android:gravity="left"/>

    </LinearLayout>

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

        <TextView style="@style/GroupName"
                  android:text="@string/foursquare_badges"/>

        <GridView android:id="@+id/foursquare_grid"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:columnWidth="90dp"
                  android:numColumns="auto_fit"
                  android:verticalSpacing="10dp"
                  android:horizontalSpacing="10dp"
                  android:stretchMode="columnWidth"
                  android:gravity="left"/>

    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我对此并不满意,因为你可以看到右上方图标的标签是隐藏的.我可以点击并滚动,但这不是我想要的.更大的问题是每个人都GridView拥有自己的滚动条.再也不是我想要的.所以我想我想用一个GridView来完成这个.如何使用a GridView来显示图标,然后在图标中间显示GroupName.我知道我可以创建一个BaseAdapter返回不同类型的视图,但我需要有一个项目,水平占据整个空间.这可能吗?

编辑:

我想一个更好的问题是如何创建分组GridView?

Che*_*mon 0

我不确定您现在如何添加项目,但您可能会考虑使用SimpleAdapter。它允许您提供 xml 布局并将数据对象中的项目映射到 xml 布局中的位置。如果您快速搜索,有很多使用它的教程。