2016-03-04 46 views
0

我想添加一个空的视图,高度为30dp低于我的gridview但不幸的是,我无法看到预期的结果。 唯一可见的是gridview查看未被插入

如何显示空的查看全部内容gridview都呈现?

这里是我的代码:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorPrimary"> 

    <GridView 
     android:id="@+id/list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:numColumns="3" 
     android:background="@color/colorAccent" 
     /> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_below="@id/list" 
     android:background="@color/colorPrimaryDark"/> 

</RelativeLayout> 

这是我的电流输出。 enter image description here

回答

2

编辑:

有,你可以用它来实现你要寻找的许多变通方法。

在我看来,使用专用库可能是轻量级的最佳选择。

看一看这样的:GridViewWithHeaderAndFooter

从文档:

GridViewWithHeaderAndFooter gridView = (GridViewWithHeaderAndFooter) v.findViewById(R.id.ly_image_list_grid); 

LayoutInflater layoutInflater = LayoutInflater.from(this); 
View headerView = layoutInflater.inflate(R.layout.test_header_view, null); 
View footerView = layoutInflater.inflate(R.layout.test_footer_view, null); 
gridView.addHeaderView(headerView); 
gridView.addFooterView(footerView); 
+0

还是......只有GridView控件是可见的。 –

+0

您是否复制了整个布局?注意根应该是一个垂直方向的LinearLayout – Matteo

+0

我做了同样的...仍然是这样。 :( –