2016-03-04 22 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

我做了同樣的...仍然是這樣。 :( –