Android Animation Questions
1.
1 AnimationSet exitTransition = new AnimationSet(true); 2 exitTransition.setDuration(1000); 3 int xoffset=getResources().getDimensionPixelSize(R.dimen.list_width); 4 int yoffset=getResources().getDimensionPixelSize(R.dimen.topbar_height); 5 float xscale=(mShelvesView.getWidth()-xoffset)/(float)mShelvesView.getWidth(); 6 TranslateAnimation trans = new TranslateAnimation( 7 Animation.ABSOLUTE, 0, Animation.ABSOLUTE, xoffset, 8 Animation.ABSOLUTE, 0, Animation.ABSOLUTE, yoffset); 9 ScaleAnimation scales= new ScaleAnimation(1f,xscale,1f,1f); 10 exitTransition.addAnimation(scales); 11 exitTransition.addAnimation(trans); 12 exitTransition.setFillAfter(true); 13 mShelvesView.startAnimation(exitTransition);
I create an animation ues this code in Android 4.0,and it runs properly.However ,when I run it on Android 3.1 device,the animation process is gone.It directly jump to the last position.
Answers:
add this two lines :
trans.setDuration(1000);
scales.setDuration(1000);
then it will be ok.