MotionLayout: MotionScene OnClick overrides setOnClickListener

后端 未结 7 1560
庸人自扰
庸人自扰 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:28

    You can also just handle the click programmatically from the beginning by removing

     
    

    altogether. Also it is easy to see whether or not your view is expanded by checking the progress of your transition. So you can programmatically handle it in your java/kotlin file with

    yourButton.setOnClickListener {
        if (yourMotionLayoutId.progress == 0.0)
            yourMotionLayoutId.transitionToEnd
    }
    

    This way, it will check if the transition is in the state where it has not occurred (progress will be 0.0) and transition, otherwise, it will do nothing.

提交回复
热议问题