Android gridview 和自定义标题

标签 android gridview

我正在努力实现以下 GUI:

enter image description here

对于红线下方的 9 个元素(红线下方的所有内容都应该是可滚动的),我使用了按预期工作的 gridview 布局。但实际上我不知道如何制作页眉。

到目前为止我的 xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   android:background = "@drawable/t"
   tools:context=".AppStarter" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center">
    <GridView 
        android:id="@+id/gridview"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:numColumns="3"
        android:verticalSpacing="10dp"
        android:horizontalSpacing="10dp"
        android:stretchMode="columnWidth"
        android:gravity="center"
        android:layout_marginLeft="2sp"
        android:layout_marginRight="5sp"
        android:layout_marginTop="0sp" />
 </LinearLayout>
</RelativeLayout>

我的想法是在 gridview 上添加一个额外的 linearLayout,但这种方法没有产生预期的结果。有什么想法可以实现这个 header 吗?

提前致谢!

最佳答案

你可以试试我自己的实现。经过多次尝试,我决定编写自己的代码!

https://github.com/munix/GridViewHeader

关于Android gridview 和自定义标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20668112/

相关文章:

android - 基于 ICS 的日历小部件的 Gridview

c# - 使用 GridView1_SelectedIndexChanged 时出错

.net - 如何隐藏 WPF ListView 的 header ?

java - 如何设置 ImageView 的角半径

android - 获取图标 native android?

php - 在右侧对齐图像

c# - 在 gridview edititemtemplate 中绑定(bind)下拉列表

安卓.view.InflateException :Error inflating class Button

Android 3.0 WebView 崩溃

android - Android App 和 Android Library 之间的 GCM 冲突