RecyclerView没有占据全高

时间:2016-04-18 11:13:36

标签: android android-layout android-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填满整个屏幕的内容?

1 个答案:

答案 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

相关问题