I have an xml with elements like below
<ConstraintLayout>
<ImageView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/nestedScrollView"
/>
<TextView/>
<TextView/>
<NestedScrollView
android:layout_width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/iv_avatar"
>
<LinearLayout orientation="vertical">
<RecyclerView
android:layout_width="match_parent"/>
<RecyclerView
android:layout_width="match_parent"/>
<RecyclerView
android:layout_width="match_parent"/>
<LinearLayout/>
<NestedScrollView/>
<ConstraintLayout/>
the issue is that the children of the first RecyclerView don't take the correct width that they can. (on the children xml the width is set to wrap_content
)
if I change the android:layout_width="match_parent"
of one of the 3 RecyclerViews to wrap_content
then all the elements get the correct size
example images with wrap_content
on the 3rd RecyclerView (1st image from designer, 2nd from emulator)
example images with match_parent
on all RecyclerViews (1st image from designer, 2nd from emulator)
gif to see the change I am saying
working has is to add as a child of the LinearLayout
a View
like this one
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content" />