QuantityPickerView icon indicating copy to clipboard operation
QuantityPickerView copied to clipboard

Wrong measure specs inside ConstraintLayout when using 0dp

Open GuilhE opened this issue 5 years ago • 0 comments

Describe the bug

When QuantityPickerView is child of a ConstraintLayout and it's width is 0dp (to take into account constraints) it receives wrong measures specs and the layout_width will be randomly wrong calculated.

To Reproduce

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="50dp">
       
        <com.github.guilhe.views.QuantityPickerView
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent"
                 app:layout_constraintBottom_toBottomOf="parent" />
    
</androidx.constraintlayout.widget.ConstraintLayout>

Expected behavior

No problems with measure specs

Details:

  • Library version: 1.2.4

Additional context

To fix this problem - for now - we have 2 options:

  1. Don't use 0dp, give it a fixed width value
  2. Add it as a child of FrameLayout and give constraints restrictions to the FrameLayout:
<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="50dp">
    
        <FrameLayout
                android:id="@+id/quantityPickerView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">
                
                <com.github.guilhe.views.QuantityPickerView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          app:value="@{item.quantity}" />
        </FrameLayout>
    
</androidx.constraintlayout.widget.ConstraintLayout>

GuilhE avatar Oct 09 '20 09:10 GuilhE