MotionLayout: MotionScene OnClick overrides setOnClickListener

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

    1. Not that I can find.
    2. I found success using the clickAction attribute with the "transitionToEnd" value. This will make it so that the motionlayout cannot go back to the startConstraintSet.
    
    
    1. That is the namespace I am using, as well as the namespaced used in examples I've seen.

    Just ran into the same issue today. I was able to intercept the click by using setOnTouchListener instead of setOnClickListener in my code.

    rateUsButton.setOnTouchListener { _, event ->
        if (event.action == MotionEvent.ACTION_UP) {
            // handle the click
        }
        false
    }
    

    I know this solution isn't the best but I didn't find another option. Returning false means the touch was not handled here and thus will be handled by the motion layout.

提交回复
热议问题