【发布时间】:2017-06-01 18:20:08
【问题描述】:
我想在 TextView 上制作一个基本动画,当用户点击它时它会缩小,然后缩小到原始大小以提供视觉反馈。阅读文档,似乎有多种方法可以在 Android 上为属性设置动画,但我决定使用视图动画,在以下 XML 中定义:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="true" android:interpolator="@android:anim/accelerate_interpolator">
<scale
android:fromXScale="1.0"
android:toXScale="0.5"
android:fromYScale="1.0"
android:toYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="100"/>
<scale
android:startOffset="100"
android:fromXScale="1.0"
android:toXScale="2.0"
android:fromYScale="1.0"
android:toYScale="2.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="50"/>
这工作得很好,但让我感到奇怪的是,我必须计算我需要缩放第二个标签的程度,而不是只能使用相对于原始标签的值。有没有办法在第二个标签中使用相对于原始元素的值(即,使用 fromXscale="0.5" 和 toXscale="1.0")?
【问题讨论】: