Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong measure specs inside ConstraintLayout when using 0dp #7

Open
GuilhE opened this issue Oct 9, 2020 · 0 comments
Open

Wrong measure specs inside ConstraintLayout when using 0dp #7

GuilhE opened this issue Oct 9, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@GuilhE
Copy link
Owner

GuilhE commented Oct 9, 2020

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 GuilhE added the bug Something isn't working label Oct 9, 2020
@GuilhE GuilhE self-assigned this Oct 9, 2020
@GuilhE GuilhE changed the title Wrong measure specs inside ConstraintLayout using 0dp Wrong measure specs inside ConstraintLayout when using 0dp Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant