我想使用ScaleAnimation每次单击生成一个视图.在完成fillAfter之后我已经管理了动画的效果,但现在的问题是,动画总是从状态0开始(因为视图在XML中定义) - 点击视图重置并动画回来到了第一个动画之后的状态.
动画以XML定义:
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="1"
android:toXScale="1.5"
android:fromYScale="1"
android:toYScale="1.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:fillAfter="true"
/>
Run Code Online (Sandbox Code Playgroud)
Anz*_*nze 26
我解决了这个问题,不是诉诸XML中定义的动画,而是采取行动
anim = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Run Code Online (Sandbox Code Playgroud)
并且每次我需要扩展它时调整/到.我不太确定这对于性能是一件好事,但是效果很好.