Android 查看相对于原始对象的动画比例值

Android 查看相对于原始对象的动画比例值,android,android-animation,Android,Android Animation,我想在TextView上制作一个基本动画,当用户点击它时,它会缩小,然后缩小到原始大小,以便提供视觉反馈。在阅读文档时,似乎有各种方法可以在Android上设置属性动画,但我决定使用视图动画,该动画在以下XML中定义: <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="true" android:interpolator="@android:anim/acce

我想在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”)

如果我没弄错你的问题,试试这个

tv.animate().scaleXBy(2.0f).scaleYBy(2.0f).setDuration(100).setInterpolator(new LinearInterpolator()).start();

您可以添加反向重复策略,也可以只添加缩放动画。

如果我没有弄错您的问题,请尝试此操作

tv.animate().scaleXBy(2.0f).scaleYBy(2.0f).setDuration(100).setInterpolator(new LinearInterpolator()).start();

<>你可以添加反向重复策略,或者只是添加回缩动画。

谢谢,我甚至没有考虑使用反向重复来避免不得不做第二个动画。这很好。谢谢,我甚至没有考虑过使用反向重复来避免做第二个动画。这很有效。