respect animator duration scale in own animation

2019-04-07 21:44发布

问题:

how can I respect the animator duration scale setting in own animations? Can I read the setting and multiply it to my duration or what is a good way for this?

回答1:

You can try something like this:

    final float animatorSpeed;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        animatorSpeed = Settings.Global.getFloat(
                context.getContentResolver(),
                Settings.Global.ANIMATOR_DURATION_SCALE,
                0);
    } else {
        animatorSpeed = Settings.System.getFloat(
                context.getContentResolver(),
                Settings.System.ANIMATOR_DURATION_SCALE,
                0);
    }