我想却与点击使用ScaleAnimation视图。我已经成功了动画的影响持续存在后,已与fillAfter完成,但现在的问题是,动画总是从状态0开始(作为视图在XML定义) - 点击视图复位和动画回的状态,这只是第一个动画后。
动画在一个XML定义的:
<规模
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:插=@机器人:动画/ accelerate_decelerate_interpolator
机器人:fromXScale =1
机器人:toXScale =1.5
机器人:fromYScale =1
机器人:toYScale =1.5
机器人:pivotX =50%
机器人:pivotY =50%
机器人:时间=1000
机器人:fillAfter =真
/>
解决方案
我通过不诉诸于XML定义动画,而是做解决了问题。
动画=新ScaleAnimation(从,到,从,到,Animation.RELATIVE_TO_SELF,0.5F,Animation.RELATIVE_TO_SELF,0.5F);
和从/到我需要扩大它每次调整。我不太确定这是关于性能是一件好事,但它工作得很好。
I'd like to grow a view with each click using a ScaleAnimation. I've managed the effects of the animation persist after it has finished with the fillAfter, but the problem now is, the animation always starts from state 0 (as the View is defined in the XML) - on click the view resets and animates back to the state it was just after the first animation.
The animation is defined in an 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"
/>
解决方案
I solved the issue by not resorting to animation defined in the XML, but rather doing
anim = new ScaleAnimation(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
and adjusting from/to each time I needed to expand it. I'm not so sure that's a good thing regarding performance, but it works nicely.
相关推荐
最新文章