Android Activity切换动画效果的修改

Activity的动画效果在\android\frameworks\base\core\res\res\values下的stlyes.xml,themes.xml两个文件中有定义。 
但是有时这些效果未必能满足你的要求,需要自己定义styles.xml来实现这个功能。 

Activity去掉默认的动画效果方法: 

1.重写Activity的Them中的windowAnimationStyle相关属性,并保存在res/values/styles.xml 

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme" parent="android:Theme">

        <item name="android:windowAnimationStyle">@style/Animation</item>

    </style>
    <style name="Animation">

        <item name="android:activityOpenEnterAnimation">@null</item>

        <item name="android:activityOpenExitAnimation">@null</item>

        <item name="android:activityCloseEnterAnimation">@null</item>

        <item name="android:activityCloseExitAnimation">@null</item>

        <item name="android:taskOpenEnterAnimation">@null</item>

        <item name="android:taskOpenExitAnimation">@null</item>

        <item name="android:taskCloseEnterAnimation">@null</item>

        <item name="android:taskCloseExitAnimation">@null</item>

        <item name="android:taskToFrontEnterAnimation">@null</item>

        <item name="android:taskToFrontExitAnimation">@null</item>

        <item name="android:taskToBackEnterAnimation">@null</item>

        <item name="android:taskToBackExitAnimation">@null</item>

    </style>
</resources>

2.在不想有动画的Activity上设置此属性即可 

<activity android:name=".yourActivity"
            android:label="@string/app_name"
            android:screenOrientation="nosensor"
            android:theme="@style/Theme">



你可能感兴趣的:(android,animation,encoding,frameworks)