Art*_*yom 7 android android-layout android-motionlayout
我将使用 MotionLayout 为文本大小更改设置动画。
我为开始状态执行以下操作
<CustomAttribute
motion:attributeName="textSize"
motion:customDimension="16sp" />
Run Code Online (Sandbox Code Playgroud)
以及以下结束状态
<CustomAttribute
motion:attributeName="textSize"
motion:customDimension="14sp" />
Run Code Online (Sandbox Code Playgroud)
结果,看起来大小实际上在变化,但它比14sp-16sp大得多
那么,如何正确改变文字大小呢?
尝试这个
<CustomAttribute
motion:attributeName="textSize"
motion:customFloatValue="14" />
Run Code Online (Sandbox Code Playgroud)
尝试使用scale属性为字体大小设置动画,因为它是Double类型而不是 textSize (Integer)。动画会更清晰,因为 Double 缩放更平滑。
<ConstraintSet
android:id="@id/start">
<Constraint
android:id="@id/element"
android:scaleX="1.0"
android:scaleY="1.0"/>
</ConstraintSet>
<ConstraintSet
android:id="@id/end">
<Constraint
android:id="@id/element"
android:scaleX="0.5"
android:scaleY="0.5"/>
</ConstraintSet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4244 次 |
| 最近记录: |