wal*_*lli 5 xml android android-animation android-layout android-motionlayout
我想在我的片段显示时自动启动动画。我已将该autoTransition属性设置为animateToEnd,但没有任何反应。我目前在constraintLayout beta7。当降级到 beta6 或更低版本时,除了片段进入屏幕时动画完成之外,什么也不会发生。我已经将 TransitionListener 附加到 MotionLayout 并观察到以下内容:
这是 MotionScene xml 文件:
<?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">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="1000"
motion:motionInterpolator="easeInOut"
motion:autoTransition="animateToEnd">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint android:id="@id/splash_head_TextView">
<Layout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="@id/topGuideLine"/>
<CustomAttribute
motion:attributeName="alpha"
motion:customFloatValue="0.0" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint android:id="@id/splash_head_TextView">
<Layout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/splash_head"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="@id/topGuideLine"/>
<CustomAttribute
motion:attributeName="alpha"
motion:customFloatValue="1.0" />
</Constraint>
</ConstraintSet>
</MotionScene>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它不起作用。但我确实看到一些问题/可以改进。
android:text="@string/splash_head" 不是布局命令 Alpha 是执行 Alpha 的更好方法
由于没有其他任何改变,这应该就是您所需要的。
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="1000"
motion:autoTransition="animateToEnd">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint android:id="@id/splash_head_TextView">
<PropertySet android:alpha="0.0" >
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint android:id="@id/splash_head_TextView">
<PropertySet android:alpha="1.0" >
</Constraint>
</ConstraintSet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1207 次 |
| 最近记录: |