如何从我的代码中启用Animator持续时间缩放?

时间:2018-10-22 18:50:53

标签: android android-animation

我在遇到此问题时遇到麻烦,我需要从代码中启用它,因为某些用户禁用了此选项,我该怎么做?到目前为止,我已经尝试过了,但是没有运气。

选项1:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
     Settings.Global.getFloat(
            getApplicationContext().getContentResolver(),
            Settings.Global.ANIMATOR_DURATION_SCALE,
            1f);

} else {
   Settings.System.getFloat(
            getApplicationContext().getContentResolver(),
            Settings.System.ANIMATOR_DURATION_SCALE,
            1f);
}

选项2:

durationScale = Settings.Global.getFloat(getApplication().getContentResolver(),
                Settings.Global.ANIMATOR_DURATION_SCALE, 1);
   if (durationScale != 1) {
            try {
                ValueAnimator.class.getMethod("setDurationScale", float.class).invoke(null, 1f);
                durationScale = 1f;
                Log.v("NOSEQUEPEX","HOLA");
            } catch (Throwable t) {
               Log.v("VALIOSHIT",String.valueOf(t));
            }
        }

希望有人可以帮助我谢谢你。

0 个答案:

没有答案