android - MotionLayout:如何为边距设置动画
问题描述
我正在使用MotionLayout
动画将视图的大小从全屏调整为具有特定边距的较小尺寸(如下所示)。它大部分工作正常,但显示的边距为 0,直到动画结束,然后立即应用它们。有什么办法也可以为这些设置动画吗?
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/localVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/localVideoView"
android:layout_width="68dp"
android:layout_height="120dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="16dp"
android:layout_marginBottom="92dp"/>
</ConstraintSet>
我尝试使用KeyFrameSet
创建具有不同边距值的中间点,但这没有效果。
例如
<KeyFrameSet>
<KeyAttribute
app:framePosition="50"
app:target="@id/localVideoView">
<CustomAttribute
motion:attributeName="layoutMarginBottom"
motion:customDimension="92dp" />
</KeyAttribute>
</KeyFrameSet>
更新
所以,看起来问题与我正在使用的事实有关SurfaceView
......如果我尝试使用ImageView
例如边距确实会逐渐变化。
解决方案
SurfaceView 不允许适当的转换,如果您需要转换,您应该使用 TextureView。
推荐阅读
- mongodb - MongoDB 和 Ubuntu 中的身份验证
- tensorflow - TensorFlow MultiRNNCell 保存和恢复
- python - RDS:无法获取在 boto3 describe_events 中显示为空白的事件
- php - Laravel 5.6 spatie/laravel-sitemap 生成默认xml行且无路由
- python - 如果我的包在 2.x 上,我可以发布 1.x 更新吗?(皮皮)
- node.js - NodeJS Stream 通过 async/await 错误返回
- javascript - Javascript 获取字符串出现次数
- java - 无法导入assertThat方法junit
- reactjs - Electron 应用程序启动时间过长
- python-3.x - Python TF 对象检测!找不到对象检测