2016-04-18 20 views
0

我正在做一个简单的布局,但我发现RecyclerView无法占据全高,但它包裹了其内容的高度。RecyclerView不占用全高

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/gridList" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@mipmap/bg_list" /> 
</LinearLayout> 

结构非常简单。我错过了什么让RecyclerView填满整个屏幕?

+0

你能告诉我们图像吗? –

回答

0

新增布局应填充屏幕高度。如果我在没有背景的情况下使用您的布局,我可以看到正确的输出。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/gridList" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</LinearLayout> 

这个问题似乎在android:background="@mipmap/bg_list"。检查可能影响身高的bg_list