首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于GridView的GridView

关于GridView的GridView
EN

Stack Overflow用户
提问于 2018-01-08 01:14:58
回答 1查看 51关注 0票数 0

我需要在另一个GridView上的网格视图。

借助于这一点:how to set Multiple gridview in same layout in android?

我可以在一个布局中设置两个网格视图。我需要它们都放在一个SwipeRefreshLayout中!

代码语言:javascript
复制
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:baselineAligned="false">

    <GridView
        android:id="@+id/GridView1"
        android:layout_width="465dp"
        android:layout_height="101dp"
        android:layout_marginBottom="100dp"
        android:layout_weight="1"
        android:numColumns="1"
        android:padding="1dp" />

    <GridView
        android:id="@+id/GridView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:layout_weight="1"
        android:footerDividersEnabled="false"
        android:numColumns="3"
        android:padding="1dp" />

</LinearLayout>


</android.support.v4.widget.SwipeRefreshLayout>

但它们是相邻的,我不能将它们中的一个设置为另一个。你可以在图片中看到我的问题。

如果你知道如何把一个放在另一个上面,这样两个都能填满所有的宽度,请帮助我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-08 01:22:35

更改XML属性,如下所示:

代码语言:javascript
复制
<android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >

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

    <GridView
        android:id="@+id/GridView1"
        android:layout_width="match_parent"
        android:layout_height="101dp"
        android:numColumns="1"
        android:padding="1dp" />

    <GridView
        android:id="@+id/GridView2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:footerDividersEnabled="false"
        android:numColumns="3"
        android:padding="1dp" />

    </LinearLayout>

</android.support.v4.widget.SwipeRefreshLayout>

如果您总是需要在first GridView(GridView1)中使用1列,我建议您使用RecyclerView。

希望它能帮上忙!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48139614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档