机器人ObjectAnimator.ofFloat不能正常工作 [英] Androids ObjectAnimator.ofFloat doesn't work properly

查看:1782
本文介绍了机器人ObjectAnimator.ofFloat不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ObjectAnimator.ofFloat在一个Android应用程序至极的所有设备都以同样的方式是行不通的。

I've used ObjectAnimator.ofFloat in an Android App wich doesn't work on every Device the same way.

MainActivity(延伸活动):

Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        startAnimation();
    }
});


public void startAnimation() {
    ImageView aniView = (ImageView) findViewById(R.id.imageView1);
    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(aniView, "alpha", 0f);
    fadeOut.setDuration(2000);

    ObjectAnimator mover = ObjectAnimator.ofFloat(aniView, "translationX", -500f, 0f);
    mover.setInterpolator(new TimeInterpolator() {
        @Override
        public float getInterpolation(float input) {
            Log.v("MainActivity", "getInterpolation() " + String.format("%.4f", input));
            return input;
        }
    });
    mover.setDuration(2000);

    ObjectAnimator fadeIn = ObjectAnimator.ofFloat(aniView, "alpha", 0f, 1f);
    fadeIn.setDuration(2000);

    AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(mover).with(fadeIn).after(fadeOut);
    animatorSet.start();
}

三星Galaxy S4(安卓4.4.2):

    getInterpolation() 1,0000
    getInterpolation() 1,0000

三星Galaxy S5(安卓4.4.2):

    getInterpolation() 0,0000
    getInterpolation() 0,0000
    getInterpolation() 0,0085
    getInterpolation() 0,0170
    getInterpolation() 0,0255
    ...
    ...
    getInterpolation() 0,9740
    getInterpolation() 0,9825
    getInterpolation() 0,9910
    getInterpolation() 0,9995
    getInterpolation() 1,0000

有没有人一个想法,为什么这不能正常工作?

Has anyone an Idea, why this doesn't work properly?

推荐答案

在Galaxy S4,下的开发人员选项的,有选择的动画时长比例的。对于一些野生的原因,这是的关闭的默认。切换这之后的 1X 的,我的动画在S4开始正常工作。这可能是什么原因造成你的问题。

On the Galaxy S4, under Developer Options, there is the option Animator duration scale. For some wild reason, this is off by default. After switching this to 1x, my animations on the S4 started to work perfectly. This may be what is causing your problem.

这篇关于机器人ObjectAnimator.ofFloat不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆