android - Android - Motion Layout 过度拉伸效果
问题描述
我想在约束布局 2.1 中滑动时实现拉伸功能。我有我想在向下滑动视图时扩展的motionlayout。如果我使用新的 Spring 属性,只有当我让过渡自动完成时,我才会获得很好的超调效果,但是如果我完全通过滑动完成动画,它会停止而没有任何弹簧效果。我想要有过度拉伸效果,当我释放它时,应该有一些基于弹簧值的弹簧动画。可能吗?
这是我当前的代码
<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/motionLayout"
app:layoutDescription="@xml/scene_02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:focusableInTouchMode="false"
android:background="@color/black_semi"
app:layout_constraintStart_toStartOf="parent">
<View
android:id="@+id/area"
android:layout_width="1dp"
android:layout_height="1dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<View
android:id="@+id/button"
android:background="@color/error_red"
android:layout_width="164dp"
android:layout_height="34dp"
android:layout_marginBottom="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
</androidx.constraintlayout.motion.widget.MotionLayout>
运动文件
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000">
<OnSwipe
motion:springStiffness="80"
motion:springDamping="5"
motion:autoCompleteMode="spring"
motion:dragDirection="dragDown"
motion:touchAnchorId="@id/button"
motion:touchRegionId="@id/button"
motion:touchAnchorSide="bottom" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint android:id="@id/button">
<Layout
android:layout_width="164dp"
android:layout_height="34dp"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="20dp" />
</Constraint>
</ConstraintSet>
<ConstraintSet
android:id="@+id/end"
motion:deriveConstraintsFrom="@id/start">
<Constraint android:id="@id/button"
motion:quantizeMotionInterpolator="overshoot">
<Layout
android:layout_width="164dp"
android:layout_height="34dp"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="200dp" />
</Constraint>
</ConstraintSet>
</MotionScene>
解决方案
伙计,把运动布局抛在脑后,你需要动画吗?尝试使用撰写
推荐阅读
- reactjs - 如何使用带有钩子的上下文进行身份验证?
- javascript - 引导向导 | class="active" 添加到错误的元素
- generics - OpenAPI (Swagger) 规范是否支持架构的通用对象?
- toast-ui-chart - Toast UI Chart 的导出菜单和工具提示不起作用
- php - PHP文件中的图像
- javascript - Firebase 无需在 querySnapshot 上运行 forEach 循环即可获取集合文档数据
- ruby-on-rails - 为什么捆绑安装没有运行?
- reactjs - 使用 laravel 作为后端 API 和 react js 作为前端的实时聊天应用程序
- python - 如何以编程方式访问美国政府提供的县级 COVID-19 检测数据?
- python - Kivy:如何阻止触摸屏事件传递到桌面