昨天制作了按钮由下往上的动画,今天要加上变化,让昨天的动画看起来不那麽单调。
<?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">
<!-- 动画样式 -->
<OnSwipe motion:dragDirection="dragUp"
motion:touchAnchorId="@id/button"
motion:touchAnchorSide="top"/>
<KeyFrameSet>
<KeyPosition
motion:motionTarget="@+id/button"
motion:framePosition="75"
motion:keyPositionType="pathRelative"
motion:percentY="-0.25" />
<KeyPosition
motion:motionTarget="@+id/button"
motion:framePosition="25"
motion:keyPositionType="pathRelative"
motion:percentY="0.25" />
<KeyAttribute
motion:motionTarget="@+id/button"
motion:framePosition="50"
android:alpha="0.1" />
</KeyFrameSet>
</Transition>
...下面都一样 故省略..
</MotionScene>
KeyPosition: 位置的变化
KeyAttribute: 属性的变化
还是不知道差别的可以到此了解
自订义属性
<?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
motion:layout_constraintVertical_bias="0.877"
android:layout_height="wrap_content"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:id="@+id/button" >
<CustomAttribute
motion:attributeName="backgroundColor"
motion:customColorValue="#00FF99" />
<CustomAttribute
motion:attributeName="textColor"
motion:customColorValue="#555555" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
motion:layout_constraintVertical_bias="0.109"
android:layout_height="wrap_content"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:id="@+id/button" >
<CustomAttribute
motion:attributeName="backgroundColor"
motion:customColorValue="#C59EFB" />
<CustomAttribute
motion:attributeName="textColor"
motion:customColorValue="#0000FF" />
</Constraint>
</ConstraintSet>
</MotionScene>
我将开启的button跟button text改了颜色,当动画结束时会做颜色的变化
有了 User Story,已经能够了解产品会有哪些角色、他们的需求及功能价值。但缺少的是这些需求...
由於感觉我这前几天的文章都字数以及内容都蛮少的,简单来说就只是想低空 飞过,打混过关;结果想透过...
承接常见网路问题(一)、(二),我们最後来看看第 3 条路径的错误排除。 *透过 Wi-Fi 到网际...
1.前言 各位有理解loop中很长的咒语吗?不懂得可以多看几次,不要气馁,文章不会跑走,所以继续加油...
使用SuperTest 使用SSR时,你要负责回应正确的HTTP Status Code。 因为牵涉...