添加GridView下方的按钮

时间:2011-02-22 05:35:35

标签: android

我正在尝试在GridView下面添加一个按钮。我也尝试使用RelativeLayoutLinearLayout。但按钮不会出现。 GridView的高度也是"wrap_content"。该按钮显示在GridView后面。

如何将它放在网格下面?

以下是我的布局无效

      <GridView android:id = "@+id/galleryGridView" android:layout_width = "wrap_content" android:layout_height = "wrap_content"
        android:padding = "1dip" android:verticalSpacing = "1dip" android:horizontalSpacing = "1dip" android:columnWidth = "90dip"
        android:paddingBottom = "1dip" android:numColumns = "auto_fit" android:stretchMode = "columnWidth" android:gravity = "center"/>

      <Button android:id = "@+id/loadMoreButton" android:layout_width = "fill_parent" android:layout_height = "fill_parent" 
        android:text = "Load More" android:layout_below = "@id/galleryGridView"/>

2 个答案:

答案 0 :(得分:1)

将其包裹在线性布局中,其垂直方向类似于以下内容:

<LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent" >
     <GridView  .... />
      <Button   .... />
</LinearLayout>

答案 1 :(得分:0)

查看此链接:http://developer.android.com/resources/tutorials/views/hello-relativelayout.html

我打赌你忘记为按钮添加android:layout_below =“@ id / your_grid_id_here”属性