0
On Fragment file:

override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        recycle_home.layoutManager = LinearLayoutManager( this.context , LinearLayout.VERTICAL ,false )
        recycle_home.adapter = adapter_home()

    }

enter image description here

MMG
  • 3,226
  • 5
  • 16
  • 43

2 Answers2

0
 override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState)

        recycle_home.layoutManager = LinearLayoutManager( this.context)
        recycle_home.adapter = adapter_home()

    }

Or

       override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState)

            recycle_home.layoutManager = LinearLayoutManager( this.context,RecyclerView.VERTICAL,false)
            recycle_home.adapter = adapter_home()

        }
MMG
  • 3,226
  • 5
  • 16
  • 43
0

If you are trying to add layout manager to RecyclerView you can add it inside xml itself

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/emailsRV"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:adapter="@{adapter}"
        android:layoutAnimation="@anim/layout_animation_from_bottom"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintBottom_toTopOf="@id/addNewACB"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:listitem="@layout/item_phone" />

Then if you want to add orientation you can add it in fragment or you can even create a BindingAdapter for the same

Below is the code for fragment/activity

recycle_home.addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.VERTICAL))
Abraham Mathew
  • 2,029
  • 3
  • 21
  • 42