添加页眉和页脚在Android的一个gridview页眉、Android、gridview

2023-09-06 22:48:58 作者:凉城已无爱

我想创建我的,具有以下特点的Andr​​oid应用程序,用户的个人资料页: - 标题 - GridView控件显示该用户一堆照片 - 英尺(当应用程序被下载更多的照片在GridView一个下载图标) - 标题需要与GridView控件一起移动

I am trying to create users' profile pages in my Android app with the following features: - header - gridview showing a bunch of photos from that user - footer (a downloading icon when the app is downloading more photos in the gridview) - the header needs to move together with the gridview

在换言之,简档页面上的用户体验将是非常类似于在一个Instagram的用户简档页面的用户体验。

In other words, the user experience on the profile page would be very similar to the user experience in an Instagram user profile page.

问题是,GridView控件不支持页眉和页脚。

The issue is that gridview does not support headers and footers.

任何解决方案或图书馆我可以用它来提供所需的用户体验?

Any solutions, or libraries I could use to deliver the desired user experience?

推荐答案

只需使用多个RelativeLayouts。

Just use multiple RelativeLayouts.

对齐创建于母公司顶你的头布局(50dp或其他)。然后创建第二个布局对齐到页面的底部(这将是您的页脚)。然后有另一个布局设置为下的标题和上方页脚其中将包含你的GridView。

Create your header layout (50dp or whatever) aligned to parent top. Then create a second layout aligned to the bottom of the page (this will be your footer). Then have another layout set to "below" the header and "above" the footer which will contain your GridView.

这应该是这样的:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true" >

        /* ANYTHING YOU WANT IN YOUR HEADER */

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/gridview"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/header"
        android:layout_above="@+id/footer" >

        /* GRIDVIEW HERE */

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true" >

        /* ANYTHING YOU WANT IN YOUR FOOTER */

    </RelativeLayout>

</RelativeLayout>

希望这有助于。

Hopefully this helps.