I'm still having problem with the most basic need. I wanna have 2 buttons: on开发者_运维百科e runs a tween animation that moves an image 50 pixels, the other button runs a frame by frame animation on that image.
once the tween animation is done, the frame by frame animation runs in the wrong location. weird. I'm using FillAfter/FillEnabled,
the code to run the tween animation is a basic TranslateAnimation(0, 50, 0 , 0) with the fill after and fillEnabled = true.
the frame by frame code is image.setImageDrawable(getResources().getDrawable(resourceId)); ((AnimationDrawable) image.getDrawable()).start();
help will be appreciated.
Cheers
The only way I found of doing it is first you move your imageview position, using setLayoutParams with the new margins, and only then you start the TranslateAnimation using (-x, -y, 0, 0) so for my specific case in the question, here is my code:
TranslateAnimation tweenAnim = new TranslateAnimation(-1 * XStep, -1 * YStep , 0, 0);
tweenAnim.setDuration(number_of_steps * 750);
tweenAnim.setFillAfter(true);
tweenAnim.setFillEnabled(true);
tweenAnim.setInterpolator(new LinearInterpolator());
//layout positioning
lp.leftMargin += XStep;
lp.bottomMargin += YStep;
imageView.setLayoutParams(lp);
Log.v(TAG, "leftMargin=" + lp.leftMargin);
Log.v(TAG, "bottomMargin=" + lp.bottomMargin);
imageView.startAnimation(tweenAnim);
This was a huge pain. seriously. thanks for http://www.clingmarks.com/?p=400 I was able to overcome it.
精彩评论