android / codelab-constraint-layout

Constraint Layout Codelab
https://codelabs.developers.google.com/codelabs/constraint-layout/
Apache License 2.0
469 stars 243 forks source link

gone margin end not set when using clone() method #56

Open PetarMarijanovic opened 6 years ago

PetarMarijanovic commented 6 years ago

I have set app:layout_goneMarginEnd on my view and when I clone the ConstraintSet gone margins are not cloned. I've found my view by its id in the ConstraintSet and all gone margins are set to -1.

    <TextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toStartOf="@+id/icon"
        app:layout_constraintStart_toEndOf="@+id/icon"
        app:layout_constraintTop_toTopOf="@+id/background"
        app:layout_goneMarginEnd="@dimen/gone_margin"/>
Constraint constraintSet = new ConstraintSet();
constraintSet.clone(this);

When I set it manually it works fine

constraintSet.setGoneMargin(title.getId(), ConstraintSet.END, goneMargin);
shenguojun commented 4 years ago

Update to constratlayoutandroidx.constraintlayout:constraintlayout:2.0.1 fix this issue