2016-02-28 17 views
18

私はアンドロイドスタジオで水平recyclerviewのプレビュー

tools:listitem="@layout/my_item_layour" 

を使用しますがアンドロイドスタジオは垂直リストとしてrecyclerviewをプレビューしていることにより、リスト項目をプレビューする方法を見つけました。 Androidスタジオに指示する方法はありますか?横のリストをプレビューできるように、水平のLinearLayoutManagerを添付しますか?

答えて

30

LayoutManagerを追加し、水平方向を設定します。

ここでは例:

<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" 
    /> 
+0

ニース、それは働きます! – fedepaol

+6

ツールの名前空間(ツール:orientationおよびtools:layoutManager)を使用して追加することもできます。その後、IDEプレビューにのみ影響し、コード内でこれらの値を設定し続けることができます。 – gMale

+2

@gMaleいいえ、ツールの名前空間が機能しませんでした。 –

0

そうでない場合は、Javaファイルで使用することができます。

mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true)); 
+0

質問は実際の実装ではなく、アンドロイドスタジオのプレビューで確認することです。 –