Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Previewing horizontal recyclerview in android studio

I found out how to preview a list item by using

tools:listitem="@layout/my_item_layout" 

Android studio however is previewing the recyclerview as a vertical list. Is there a way to tell Android Studio to display the layout preview in a horizontal fashion using LinearLayoutManager?

like image 736
fedepaol Avatar asked Feb 28 '16 10:02

fedepaol


People also ask

How can show layout in RecyclerView in XML?

Just right-click the RecyclerView in the layout editor and choose "Preview list content".


1 Answers

Add a LayoutManager and set a horizontal orientation.

Here an example:

<android.support.v7.widget.RecyclerView     android:id="@+id/homesRecyclerView"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"     app:layoutManager="android.support.v7.widget.LinearLayoutManager"     android:layout_centerVertical="true"     /> 
like image 126
L.Velazquez Avatar answered Oct 08 '22 03:10

L.Velazquez