【发布时间】:2020-05-15 12:17:22
【问题描述】:
我正在尝试在滑动时为 textview 的边距、填充和 alpha 设置动画。 开始时,textview 没有填充,alpha 为 1。 最后,我希望 alpha 为 0,padding 为 100dp,边距为 16dp dp,alpha 为 0.5 一切正常,除了填充没有改变。 MotionLayout 是否支持填充? 我正在使用 androidx.constraintlayout:constraintlayout:2.0.0-beta4。
添加更多文本,因为 SO 说我的帖子看起来主要是代码... 添加更多文本,因为 SO 说我的帖子看起来主要是代码...... 添加更多文字,因为 SO 说我的帖子看起来主要是代码......
布局xml:
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/test">
<TextView
android:id="@+id/fakenavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="hello world">
</TextView>
</androidx.constraintlayout.motion.widget.MotionLayout>
运动场景:
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/fakenavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="1"
android:padding="100dp"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintStart_toStartOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/fakenavigationBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:alpha="0.5"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintBottom_toBottomOf="parent">
</Constraint>
</ConstraintSet>
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:duration="2000"
motion:motionInterpolator="linear">
<OnSwipe
motion:touchAnchorId="@+id/fakenavigationBar"
motion:touchAnchorSide="top"
motion:dragDirection="dragDown"/>
</Transition>
</MotionScene>
【问题讨论】:
-
如果您解释您想要实现的目标或分享屏幕截图,也许其他人会更理解
-
我在问题中添加了更多细节。
-
这里有人吗?像真的一样,有人吗?我该怎么做才能让人们看到这篇文章并帮助我?
标签: android animation padding android-motionlayout