您的位置:首页 > 其它

activity 转场动画(全局)---随手

2017-02-24 18:40 288 查看
###1.在application里面进行添加

  android:theme="@style/MyTestAppTheme"

###2. MyTestAppTheme

    <style name="MyTestAppTheme" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="android:windowBackground">@color/white</item>

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

        <item name="windowActionBar">false</item>

        <item name="windowNoTitle">true</item>

        <item name="colorPrimary">@color/black</item>

        <item name="colorPrimaryDark">@color/black</item>

    </style>

### 3.

    <style name="AnimationActivity" parent="@android:style/Animation.Activity">

        <item name="android:activityOpenEnterAnimation">@anim/anim_enter</item>

        <item name="android:activityOpenExitAnimation">@anim/anim_exit</item>

        <item name="android:activityCloseEnterAnimation">@anim/back_enter</item>

        <item name="android:activityCloseExitAnimation">@anim/back_exit</item>
    </style>

###4.各种动画书写

anim_enter.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"

     android:shareInterpolator="false"

     android:zAdjustment="top">

    <alpha

        android:duration="300"

        android:fillAfter="true"

        android:fillBefore="false"

        android:fillEnabled="true"

        android:fromAlpha="0.0"

        android:interpolator="@android:interpolator/decelerate_cubic"

        android:toAlpha="1.0"/>

    <scale

        android:duration="300"

        android:fillAfter="true"

        android:fillBefore="false"

        android:fillEnabled="true"

        android:fromXScale="0.8"

        android:fromYScale="0.8"

        android:interpolator="@android:interpolator/decelerate_cubic"

        android:pivotX="50.0%p"

        android:pivotY="50.0%p"

        android:toXScale="1.0"

        android:toYScale="1.0"/>

</set>

anim_exit.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"

     android:background="#ff000000"

     android:zAdjustment="normal">

    <alpha

        android:duration="300"

        android:fillAfter="true"

        android:fillBefore="false"

        android:fillEnabled="true"

        android:fromAlpha="1.0"

        android:interpolator="@android:interpolator/decelerate_quint"

        android:toAlpha="0.0"/>

</set>

back_enter.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"

     android:zAdjustment="normal">

    <alpha

        android:duration="300"

        android:fillAfter="true"

        android:fillBefore=
4000
"true"

        android:fillEnabled="true"

        android:fromAlpha="1.0"

        android:toAlpha="1.0"/>

</set>

back_exit.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"

     android:shareInterpolator="false"

     android:zAdjustment="top">

    <alpha

        android:duration="300"

        android:fillAfter="true"

        android:fillBefore="true"

        android:fillEnabled="true"

        android:fromAlpha="1.0"

        android:interpolator="@android:interpolator/decelerate_cubic"

        android:toAlpha="0.0"/>

    <scale

        android:duration="300"

        android:fillAfter="true"

        android:fillBefore="true"

        android:fillEnabled="true"

        android:fromXScale="1.0"

        android:fromYScale="1.0"

        android:interpolator="@android:interpolator/decelerate_cubic"

        android:pivotX="50.0%p"

        android:pivotY="50.0%p"

        android:toXScale="0.8"

        android:toYScale="0.8"/>

</set>

项目中用到,随手进行整理.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: