我需要在另一个GridView上的网格视图。
借助于这一点:how to set Multiple gridview in same layout in android?
我可以在一个布局中设置两个网格视图。我需要它们都放在一个SwipeRefreshLayout中!
<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>但它们是相邻的,我不能将它们中的一个设置为另一个。你可以在图片中看到我的问题。
如果你知道如何把一个放在另一个上面,这样两个都能填满所有的宽度,请帮助我。

发布于 2018-01-08 01:22:35
更改XML属性,如下所示:
<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。
希望它能帮上忙!
https://stackoverflow.com/questions/48139614
复制相似问题