MotionLayout: MotionScene OnClick overrides setOnClickListener

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

    In general if you need a callback you probably will want to control the animation yourself. So if you are adding an onClick you should call the transition yourself.

    public void onClick(View v) {
       ((MotionLayout)v.getParent()).transitionToEnd());
       // you can decide all the actions and conditionals.
     }
    

    The intent was is useful what the developer does not care. hide/reveal of ui elements etc. or for testing before you get to wiring up the callbacks.

提交回复
热议问题