MotionLayout: MotionScene OnClick overrides setOnClickListener

后端 未结 7 1545
庸人自扰
庸人自扰 2021-02-13 19:02

I\'m just starting to play with MotionLayout. I have defined an activity layout using MotionLayout that uses a MotionScene to hide and sh

相关标签:
7条回答
  • 2021-02-13 19:37

    I just used this hack: click is handled programmatically, but it triggers the hidden view, on which <OnClick> is registered in MotionScene:

    actualVisibleView.setOnClickListener {
                doSomeLogic()
                hiddenView.performClick()
            }
    

    And in MotionScene:

    <Transition
            android:id="@+id/hackedTransitionThanksToGoogle"
            motion:constraintSetEnd="@layout/expanded"
            motion:constraintSetStart="@layout/closed"
            motion:duration="300"
            motion:motionInterpolator="linear">
    
            <OnClick
                motion:clickAction="transitionToEnd"
                motion:targetId="@+id/hiddenView" />
    </Transition>
    
    0 讨论(0)
提交回复
热议问题