[英]Adding a header and a footer to a gridview in Android
我試圖在具有以下功能的Android應用程序中創建用戶的個人資料頁面:-標頭-顯示該用戶的照片的gridview-頁腳(當應用程序在gridview中下載更多照片時為下載圖標)-標頭需要與gridview一起移動
換句話說,個人資料頁面上的用戶體驗將非常類似於Instagram用戶個人資料頁面上的用戶體驗。
問題是gridview不支持頁眉和頁腳。
我可以使用任何解決方案或庫來提供所需的用戶體驗嗎?
只需使用多個RelativeLayouts。
創建與父頂部對齊的頁眉布局(50dp或其他格式)。 然后創建與頁面底部對齊的第二個布局(這將是您的頁腳)。 然后將另一個布局設置為包含標題的“下方”頁眉和“上方”頁腳,其中將包含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>
希望這會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.