gpt4 book ai didi

android - 运动布局 : How to Limit the 'OnSwipe' event on a specific view instead of 'OnSwipe' on whole screen

转载 作者:行者123 更新时间:2023-12-04 11:55:53 25 4
gpt4 key购买 nike

我有一个带有以下“layoutDescription”(场景文件)的运动布局

    <Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="1000">

<OnSwipe
motion:touchAnchorId="@+id/button"
motion:touchAnchorSide="left"
motion:dragDirection="dragLeft" />

</Transition>
<ConstraintSet android:id="@+id/start">
<!-- ConstraintSet for starting -->
</ConstraintSet>

<ConstraintSet android:id="@+id/end">
<!-- ConstraintSet for end -->
</ConstraintSet>

我在这里期望的是,如果用户将“按钮”拖向左侧,那么它应该执行转换,但实际发生的是当用户从屏幕上的任何位置向左拖动(向左滑动)时,这个转换就会被执行!

如何限制动画仅在拖动指定 View 时起作用?

(我使用“constraintlayout:2.0.0-beta2”)

最佳答案

实际上对于onSwipe您可以使用 touchRegionIdtargetId对于 OnClick

关于android - 运动布局 : How to Limit the 'OnSwipe' event on a specific view instead of 'OnSwipe' on whole screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57145683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com