I have a RecyclerView
inside a HorizontalScrollView
. I don't see inside RecyclerView
all the items. I have looked and even if the list in the adapter has 7 items, onBindViewHolder
is called only 4 times! If I take out the HorizontalScrollView
, it works ok.
I use the HorizontalScrollView
because I need to scroll the list with the background of the recycle, not inside recycle, how it usually works.
So, I need a solution to scroll a list with the background of the list, or to show all the items using HorizontalScrollView
UPDATE :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:scrollbars="none"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/label">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/rlWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/paddingStartView"
android:background="@drawable/bg_round_corner">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/optionsRv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent" />
</RelativeLayout>
<View
android:id="@+id/paddingStartView"
android:layout_width="16dp"
android:layout_height="16dp" />
<View
android:id="@+id/paddingEndView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_toEndOf="@id/rlWrapper" />
</RelativeLayout>
</HorizontalScrollView>
<TextView
android:id="@+id/label"
style="@style/FontLocalizedMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textAllCaps="true"
android:textColor="#979797"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Tempareature" />
</androidx.constraintlayout.widget.ConstraintLayout>
Make the child of the HorizontalScrollView
to be RelativeLayout
instead of LinearLayout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With