Android的ScaleAnimation [英] Android ScaleAnimation

查看:115
本文介绍了Android的ScaleAnimation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想却与点击使用ScaleAnimation视图。我已经成功了动画的影响持续存在后,已与fillAfter完成,但现在的问题是,动画总是从状态0开始(作为视图在XML定义) - 点击视图复位和动画回的状态,这只是第一个动画后。

动画在一个XML定义的:

 <规模
  的xmlns:机器人=htt​​p://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.

这篇关于Android的ScaleAnimation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆