Search code examples
androidandroid-studioandroid-motionlayout

By using touchAnchorId in motion layout Buttons are not working


I used touchAnchorId so that the motion Layout applies only when i swipe through a single region because without it while scrolling on recyclerview it automatically drags Up.

<Transition
    motion:constraintSetStart="@id/start"
    motion:constraintSetEnd="@id/end"
    motion:duration="400"
    motion:motionInterpolator="linear">

    <OnClick motion:targetId="@+id/close" />

    <OnSwipe
        motion:maxAcceleration="800"
        motion:dragDirection="dragUp"
        motion:touchRegionId="@id/constraintLayout"
        motion:touchAnchorId="@+id/constraintLayout"
        motion:touchAnchorSide="top" />

   <KeyFrameSet>
   </KeyFrameSet>

</Transition>

But after using touchAnchorId i can not use the play, skip_next & skip_previous don't know why. Can anyone help me fixing my code

Image showing start or the activity_main

buttons circled by yellow circle are not working


Solution

  • I changed

    motion:touchRegionId="@id/constraintLayout"
    

    to

    motion:touchRegionId="@id/parent_layout"
    

    and it's now working properly

    (parent_layout is the id for the whole constraint layout (the parent constraint layout in which the whole ui is defined)

    if anybody need code of whole xml file ask in comments