Android Tween动画是否总是Twitchy / Jerky?

时间:2014-02-13 19:04:27

标签: android android-animation

当我在新项目中执行简单的补间动画时,无论我是移动图像还是说按钮, 动画是生涩/抽搐。在物理设备上,例如S3& RAZR。

我做错了吗?为什么用于在IDE样板应用程序中移动视图的简单补间动画在现代(4.x)设备上会出现抽搐/生涩?

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    }

    // called from a button's on click
    public void doImageAnimation(View view) {
            ImageView iv = (ImageView)findViewById(R.id.mciamge);
            iv.setY(200f);

            ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "x",1000);
            oa.setInterpolator(new LinearInterpolator());
            oa.setRepeatCount(5);
            oa.setDuration(3000l);
            oa.start();
    }

    // called from a button's on click
    public void doButtonAnimation(View view) {                
            Button iv = (Button)findViewById(R.id.mcbutton);
            iv.setX(0f);

            ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "x",1000);
            oa.setInterpolator(new LinearInterpolator());
            oa.setRepeatCount(5);
            oa.setDuration(3000l);
            oa.start();
    }        

}

0 个答案:

没有答案