从上到下翻译图像

时间:2014-12-19 05:00:45

标签: java android

图片上下到下的动画:

我正在使用以下代码为图像设置动画,同时它适用于从右到左的动画我想做同样的从上到下,如何改进这个?

ai=new AccelerateInterpolator();
        TranslateAnimation ifr=new TranslateAnimation(Animation.RELATIVE_TO_SELF,0.04f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f);
        ifr.setDuration(400);
        ifr.setInterpolator(ai);

        set = new AnimationSet(false); 
        set.addAnimation(ifr);

        AlphaAnimation alphain=new AlphaAnimation(0.0f,1.0f);
        alphain.setDuration(2500);
        set.addAnimation(alphain);

我试过的时候:

ai=new AccelerateInterpolator();
        TranslateAnimation ifr=new TranslateAnimation(Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.02f);
        ifr.setDuration(400);
        ifr.setInterpolator(ai);

        set = new AnimationSet(false); 
        set.addAnimation(ifr);

        AlphaAnimation alphain=new AlphaAnimation(0.0f,1.0f);
        alphain.setDuration(2500);
        set.addAnimation(alphain);

但是图像在最后闪烁,即图像逐渐下降但随后又跳回到原始位置

我想要的是图像来自原始位置的2px然后稳定下来。

0 个答案:

没有答案