2017-07-20 126 views
0

我.xml文件具有下面的代码:为什么垂直方向不能垂直渲染图像?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:id="@+id/root" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.RecyclerView 
    android:orientation="vertical" 
    android:id="@+id/image_list" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
</LinearLayout> 

然而,手机呈现的图像如下:

enter image description here

为什么?

+0

我认为您必须与我们分享您的适配器和适配器项目布局。 –

回答

1

您是否为RecyclerView设置了LayoutManager?看到这个documentation

setLayoutManager

无效setLayoutManager(RecyclerView.LayoutManager布局)

设置RecyclerView.LayoutManager这RecyclerView将使用。

与其他适配器支持的视图(如ListView或GridView)相反,RecyclerView允许客户端代码为子视图提供自定义布局安排。这些安排由RecyclerView.LayoutManager控制。必须提供LayoutManager以使RecyclerView正常工作。

+0

是的,那固定了一切,谢谢。 – mercury0114