开发者

Custom TranslateAnimation causes flickering

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 onAnimat开发者_如何学运维ionEnd(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);      
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜