android-ConstraintLayoutExamples icon indicating copy to clipboard operation
android-ConstraintLayoutExamples copied to clipboard

MotionLayout 2.0.0-beta2 scene_03 XML parser error must be within a Constraint 26

Open zhangqifan1 opened this issue 7 years ago • 4 comments

XML parser error must be within a Constraint 26 how to solve it ...

zhangqifan1 avatar Aug 16 '19 07:08 zhangqifan1

<Transition
    motion:constraintSetStart="@+id/start"
    motion:constraintSetEnd="@+id/end"
    motion:motionInterpolator="linear"
    motion:duration="1000">
    <OnSwipe
        motion:touchAnchorId="@+id/iv"
        motion:touchAnchorSide="right"
        motion:dragDirection="dragRight" />
</Transition>

<ConstraintSet android:id="@+id/start">
    <Constraint
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        motion:layout_constraintBottom_toBottomOf="parent"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintTop_toTopOf="parent" />

    <CustomAttribute
        motion:attributeName="BackgroundColor"
        motion:customColorValue="#D81B60" />
</ConstraintSet>

<ConstraintSet android:id="@+id/end">
    <Constraint
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        motion:layout_constraintBottom_toBottomOf="parent"
        motion:layout_constraintEnd_toEndOf="parent"
        motion:layout_constraintTop_toTopOf="parent" />

    <CustomAttribute
        motion:attributeName="BackgroundColor"
        motion:customColorValue="#9999FF" />


</ConstraintSet>

zhangqifan1 avatar Aug 16 '19 07:08 zhangqifan1

@zhangqifan1 I think you had wrong usage in your MotionScene, you should put CustomAttribute inside the Constraint because of losing targetView binding.

Moosphan avatar Aug 16 '19 08:08 Moosphan

<Transition
    motion:constraintSetStart="@+id/start"
    motion:constraintSetEnd="@+id/end"
    motion:duration="1000">

    <OnSwipe
        motion:touchAnchorId="@+id/iv"
        motion:touchAnchorSide="right"
        motion:dragDirection="dragRight" />
</Transition>

<ConstraintSet android:id="@+id/start">
    <Constraint
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        motion:layout_constraintBottom_toBottomOf="parent"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintTop_toTopOf="parent"

        motion:attributeName="BackgroundColor"
        motion:customColorValue="#D81B60" />
</ConstraintSet>

<ConstraintSet android:id="@+id/end">

    <Constraint
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        motion:layout_constraintBottom_toBottomOf="parent"
        motion:layout_constraintEnd_toEndOf="parent"
        motion:layout_constraintTop_toTopOf="parent"

        motion:attributeName="BackgroundColor"
        motion:customColorValue="#9999FF"
        />


</ConstraintSet>
No error,but it doesn't work..

zhangqifan1 avatar Aug 16 '19 08:08 zhangqifan1

I m so sorry. I didn't see it until today <Constraint android:id="@+id/iv" android:layout_width="wrap_content" android:layout_height="wrap_content" motion:layout_constraintBottom_toBottomOf="parent"

        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintTop_toTopOf="parent" >

        <CustomAttribute
            motion:attributeName="BackgroundColor"
            motion:customColorValue="#D81B60"
            />
    </Constraint>
</ConstraintSet>

zhangqifan1 avatar Aug 19 '19 01:08 zhangqifan1