0

My custom TranslateAnimation does move a view vertically. It is fine besides a strange short flickering in the beginning. It seems that it is only one visible frame were the view flashes at a unexpected position (much higher then the animation should start).

Note: That flickering doesn't happen when i call super(0,0,0,0) but then there is no animation.

Here is a short version of my code:

public class ExTranslateAnimation extends TranslateAnimation implements AnimationListener
{
    private View myView;
    public ExTranslateAnimation (...)
    {
        // delta is how much it gets moved
        super(0, 0, -delta, 0);
        this.setAnimationListener(this);
        this.setDuration(duration);
        toY =  view.getTop() + delta;
        myView = view;
    }

    @Override
    public void onAnimationEnd(Animation animation)
    {}

    @Override
    public void onAnimationRepeat(Animation animation)
    {}

    @Override
    public void onAnimationStart(Animation animation)
    {

        LayoutParams lp = (LayoutParams) myView.getLayoutParams();
        lp.leftMargin = toX;
        lp.topMargin = toY;
        myView.setLayoutParams(lp);
        myView.layout(toX, toY, 0, 0);      
    }
}
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
ShadowMare
  • 2,087
  • 2
  • 25
  • 27

1 Answers1

1

Is it happening on emulator or device.. because i faced the same issue once but it was only in case of device. On emulator it was working fine.

Angel
  • 370
  • 1
  • 5
  • 15
  • Yes I'm facing that issue on the device. I probably don't need to try it in the emulator as it will not have enough power to handle a lot of animations. How did you solve that problem? – ShadowMare Apr 04 '11 at 11:38
  • It will not happen on emulator.... It is the memory issue. In my case i reduced the amount of memory getting used. – Angel Apr 04 '11 at 12:40
  • hmm I gonna have a look where I can improve my memory consumption but it shouldn't be that high anyway. – ShadowMare Apr 04 '11 at 19:37