After searching for a time i found this link and check is this working for Translate Animation or not and after some modification this is working for your animation too.!
See modified code below:
public class TranslateAnim extends TranslateAnimation{
public TranslateAnim(float fromXDelta, float toXDelta, float fromYDelta,
float toYDelta) {
super(fromXDelta, toXDelta, fromYDelta, toYDelta);
// TODO Auto-generated constructor stub
}
private long mElapsedAtPause=0;
private boolean mPaused=false;
@Override
public boolean getTransformation(long currentTime, Transformation outTransformation) {
if(mPaused && mElapsedAtPause==0) {
mElapsedAtPause=currentTime-getStartTime();
}
if(mPaused)
setStartTime(currentTime-mElapsedAtPause);
return super.getTransformation(currentTime, outTransformation);
}
public void pause() {
mElapsedAtPause=0;
mPaused=true;
}
public void resume() {
mPaused=false;
}
}
I'll only change class name, extends class name and constructor of this class.
you can use it like:
TranslateAnim set1, set2, set3, set4; // objects of TranslateAnim Class
set1 = new TranslateAnim(-4, 10, -110, 0); // initialize all objects like this way
animSet.addAnimation(set1); // add all animation objests in your animation set as you do before
animSet.setFillAfter(true);
and after start your animation you have only call pause and resume methods.
Thanks to Johan for share his code with us.
Hope this solve your problem. :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…