QuantityPickerView
QuantityPickerView copied to clipboard
Wrong measure specs inside ConstraintLayout when using 0dp
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:
- Don't use 0dp, give it a fixed width value
- Add it as a child of
FrameLayoutand give constraints restrictions to theFrameLayout:
<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>