禁用窗口和过渡 [英] Disable window and transition settings

查看:338
本文介绍了禁用窗口和过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我需要做的就是打开和关闭的窗口和/或过渡动画在code,来有去设置同样的效果>显示器>动画>禁用所有动画。

So what I need to do is toggle window and/or transition animations on and off in code, to have the same effect of going Settings > Display > Animations > Disable all animations.

我所熟悉的改变设备设置的方法是使用Settings.System.putInt()方法的ContentResolver的如下:

The way I am familiar with changing device settings is by using a ContentResolver within the Settings.System.putInt() method as follows:

ContentResolver cr = getContentResolver();
Settings.System.putInt(cr, Settings.System.WINDOW_ANIMATION_SCALE, 0);

由于文件设置为0将禁用所有....动画为设置中所述。当前,使用putInt()方法,用此之后读取设置:

As described in the documentation 'Setting to 0 will disable all .... animations' for both settings. When reading the setting before and after using the putInt() method, using this:

Settings.System.getString(cr, Settings.System.WINDOW_ANIMATION_SCALE);

我可以看到设置被更改。然而,当那么做一些事情,开始一个窗口或过渡动画很明显地看到,该设置并没有作出任何的区别和过渡仍然发生。

I can see that the setting is being changed. However when then doing something to begin a window or transition animation it is obvious to see that the setting hasn't made any difference and the transition still occurs.

我也想说,当我改变从设置屏幕中的设置,我可以看到的设置已经改变,当我重新运行我的应用程序。如此看来,这是正确的设置和我的应用程序不能正确地改变它。

I would also like to say that when I change the setting from within the Settings screen, I can see that the setting has been changed when I rerun my application. So it seems this is the correct setting and that my application isn't changing it correctly.

有没有别的东西我失踪?

Is there something else I'm missing?

在此先感谢。

推荐答案

检查要设置正确的尺度。

Check you are setting the correct scales.

Settings.System.TRANSITION_ANIMATION_SCALE 

将更改活动的过渡。

Will change the Activity transitions.

凡为:

Settings.System.WINDOW_ANIMATION_SCALE

将影响窗口的动画,如对话框开。

Will effect the Window animations such as Dialogs opening.

(新增API16)这将启用/禁用查看具体的动画。

(Added API16) This will enable/disable View specific animations.

Settings.System.ANIMATOR_DURATION_SCALE

另外我pretty的确保这些都是彩车,因为这些可能是0.5倍的动画设置意味着速度的一半。我以前从来没有尝试过这些从应用程序。

Also I'm pretty sure these are floats as these can be 0.5x animation settings meaning half speed. I have never tried these from an App before.

但两件事情浮现在脑海中:

But two things come to mind:

  • 的ContentProvider 是异步的,你需要听的设置来完成被设置
  • 此外,这些可能不会工作,直到您创建/完成和活动。这意味着改变他们中间活动可能不会影响当前的活动,但我会测试该理论。
  • The ContentProvider is asynchronous, and you will need to listen to the Setting to finished being set
  • Also that these will probably not work until you create/finish and activity. meaning changing them mid activity might not effect the current Activity, but I will have to test that theory.

这篇关于禁用窗口和过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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