Home » Android » android – respect animator duration scale in own animation

android – respect animator duration scale in own animation

Posted by: admin June 15, 2020 Leave a comment

Questions:

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?

How to&Answers:

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);
    }