I have the problem that my recyclerView is not scrollable. I've already packed this into a NestedScrollView - same problem. I just can't get it to show all the items and therefore be scrollable. If I change the direction from vertical to horizontal in the LinearLayoutManager everything works. What am I doing wrong?
<androidx.constraintlayout.widget.ConstraintLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView .../>
....
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cutRv"
android:layout_marginTop="20dp"
android:background="@drawable/border_cards"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
the single_item.xml for the RecyclerView:
<LinearLayout
...
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="vertical">
<RelativeLayout .../>
</LinearLayout>
Initialize the RecyclerView:
val cutAdapter = HairCutAdapter(cutsArray,this)
val recyclerView: RecyclerView = binding.cutRv
recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL
,false)
recyclerView.adapter = cutAdapter
You are using android:layout_height="wrap_content"
for RecyclerView and the height is equal to the height of all elements, then it can go beyond the screen and won't scroll, replace with android:layout_height="match_parent"
or set a specific height