RecyclerViewのLayoutManagerをxmlで指定する
RecyclerViewのLayoutManagerはxml側でも定義できます。
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
LinearLayoutManagerの方向を明示的に指定するには、 orientation
に vertical
か horizontal
を指定します。
android:orientation="vertical"
android:orientation="horizontal"
GridLayoutManagerのセルの数は、 spanCount
で指定します。
app:spanCount="2"
About me 😎

茨城県つくば市在住のソフトウェアエンジニアです。専門領域はAndroidアプリ開発で、特にアーキテクチャに興味があります。某社でAndroidアプリ開発のテックリードをしています。
Jetpack ComposeによるAndroid MVVMアーキテクチャ入門の著者です。
👉 もっと詳しく
Writing 📝
Android MVVMアーキテクチャ入門
Androidアプリ開発の初学者に向けた、MVVM(Model-View-ViewModel)アーキテクチャの入門書を書きました。初学者の方を確実にネクストレベルに引き上げる技術書です。
👉 もっと詳しく