Compose中的MotionLayout还没有内置的对((的支持。
什么是
<Transition
motion:constraintSetEnd="@id/end"
motion:constraintSetStart="@id/start"
motion:duration="1500"
motion:motionInterpolator="linear">
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@id/view1"
motion:touchAnchorSide="top" />
</Transition>
关于Compose的MotionLayout?我在这两个链接上都看不到答案:
https://github.com/androidx/constraintlayout/wiki/Introduction-to-MotionLayout-in-Composehttps://github.com/androidx/constraintlayout/wiki/Compose-MotionLayout-JSON-Syntax
我只想在手动滚动的情况下设置场景的动画,而不是像示例中那样单击按钮。
谢谢!
Compose具有滑动处理
一种方法如下:
var componentHeight by remember { mutableStateOf(1000f) }
val swipeableState = rememberSwipeableState("Bottom")
val anchors = mapOf(0f to "Bottom", componentHeight to "Top")
val mprogress = (swipeableState.offset.value / componentHeight)
然后将进度传递到MotionLayout Composable中。
MotionLayout(motionScene = "", progress = mprogress, ...)
下面是一个如何编码的例子。