没有动画切换活动 [英] switching activities without animation
问题描述
我如何使用正确的意图标志 FLAG_ACTIVITY_NO_ANIMATION
在AndroidManifest文件?我supose我的问题是微不足道的,但我不能找到很好的例子或解决方案吧。
How can I use properly the Intent flag FLAG_ACTIVITY_NO_ANIMATION
in AndroidManifest file? I supose my problem is trivial, but I can't find good example or solution to it.
<intent-filter>
<data android:name="android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION" />
</intent-filter>
但没有错误报告compliator,但数据
是不正确的。
我只是想禁用动画的情况下活动之间的切换。我可以使用 getWindow()setWindowAnimations(0);?
中的onCreate或onResume相当,但使用的标志是更好的方法,是不是
However no error is reported by compliator, but data
isn't correct.
I just want to disable animation in case switching between activities. I can use getWindow().setWindowAnimations(0);
in onCreate or onResume rather but using flag is better way, isn't it?
我可以在code也可以使用:
I can use also in code:
Intent intent = new Intent(v.getContext(), newactivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
getContext().startActivity(intent);
不过,我想用这个标志Android清单。如果还要禁用动画情况下,从第二个活动返回到第一位。
But I want to use this flag in Android Manifest. To disable animation also in case returning from second activity to first.
推荐答案
您可以创建一个样式,
<style name="noAnimTheme" parent="android:Theme">
<item name="android:windowAnimationStyle">@null</item>
</style>
并将其设置为主题,为您在清单中的活动:
and set it as theme for your activity in the manifest:
<activity android:name=".ui.ArticlesActivity" android:theme="@style/noAnimTheme">
</activity>
您还可以定义一个风格来指定自定义进入和退出动画。 <一href="http://developer.android.com/reference/android/R.attr.html#windowEnterAnimation">http://developer.android.com/reference/android/R.attr.html#windowEnterAnimation
You can also define a style to specify custom entry and exit animations. http://developer.android.com/reference/android/R.attr.html#windowEnterAnimation
这篇关于没有动画切换活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!