codelab-constraint-layout icon indicating copy to clipboard operation
codelab-constraint-layout copied to clipboard

gone margin end not set when using clone() method

Open PetarMarijanovic opened this issue 7 years ago • 1 comments

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);

PetarMarijanovic avatar Jul 19 '18 09:07 PetarMarijanovic

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

shenguojun avatar Sep 16 '20 03:09 shenguojun