-1

I'm having issues with the UI not being properly bound with the recycler view or at least not what I intend to happen. The following image is the two recycler views beside one another. Everything looks fine, but when I run the app, the children within the recycler views extend off-screen. The second image shows that. enter image description here

enter image description here

  • 2
    You need to divide `Linearlayout` in two part . Set weight to both recycler View accordingly .. Add the xml part with question instead of Images . images does not help in this case . – ADM May 26 '22 at 07:56
  • the reason i removed the android studio tag was because it seemed like you were not asking about a feature of the IDE itself and rather just added the tag because you're using the IDE – a_local_nobody May 26 '22 at 08:16
  • 1
    I found someone who was more knowledgeable who was able to answer all my questions: https://stackoverflow.com/questions/15269517/how-to-split-linear-layout-in-to-two-columns thanks anyways! – Stove Games Games May 26 '22 at 08:34

1 Answers1

0

If you are using one adapter, you can basically use GridLayoutManager for that. So, you can have 2 columns on your recycler view.

To do that with Kotlin code, just add below functionality to your recycler view reference in your fragment or activity.

recyclerView.apply {
   layoutManager = GridLayoutManager(this, 2)
}

Also, there is another way to do that in XML. You can use, app:layoutManager and app:spanCount in your recycler view.

<androidx.recyclerview.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
    app:spanCount="2" />
Berk Berber
  • 284
  • 2
  • 8