0

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 image with <code>wrap_content</code> example image with <code>wrap_content</code> emulator

example images with match_parent on all RecyclerViews (1st image from designer, 2nd from emulator)

example image with <code>match_parent</code> example image with <code>match_parent</code> emulator

gif to see the change I am saying gif

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" />
Machavity
  • 30,841
  • 27
  • 92
  • 100
gmetax
  • 3,853
  • 2
  • 31
  • 45
  • Your issue seems pretty similar to this one : https://stackoverflow.com/questions/30691150/match-parent-width-does-not-work-in-recyclerview – Sotiris S. Magionas Nov 02 '18 at 14:15
  • but isn't the same issue, I am passing the `parent` as parameter on the `inflate` call with this ext method `fun ViewGroup.inflateDataBindingView(layout: Int): T = DataBindingUtil.inflate(LayoutInflater.from(context), layout, this, false)` – gmetax Nov 02 '18 at 14:18

0 Answers0