mercury0114
mercury0114

Reputation: 1459

Why vertical orientation does not render images vertically?

My .xml file has the following code:

<?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>

However, the phone renders images as follows:

enter image description here

Why?

Upvotes: 0

Views: 32

Answers (1)

Cheticamp
Cheticamp

Reputation: 62841

Are you setting a LayoutManager for the RecyclerView? See this documentation.

setLayoutManager

void setLayoutManager (RecyclerView.LayoutManager layout)

Set the RecyclerView.LayoutManager that this RecyclerView will use.

In contrast to other adapter-backed views such as ListView or GridView, RecyclerView allows client code to provide custom layout arrangements for child views. These arrangements are controlled by the RecyclerView.LayoutManager. A LayoutManager must be provided for RecyclerView to function.

Upvotes: 1

Related Questions