Skip to content

Instantly share code, notes, and snippets.

@ok3141
Last active August 29, 2015 14:08
Show Gist options
  • Save ok3141/cd7449792d52db2dea3b to your computer and use it in GitHub Desktop.
Save ok3141/cd7449792d52db2dea3b to your computer and use it in GitHub Desktop.

###styles.xml

<style name="Theme.Custom.Dark" parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <!-- -->
    <item name="android:windowAnimationStyle">@style/Custom.Window.Animation</item>
</style>

<style name="Custom.Window.Animation" parent="@android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/custom_in_next</item>
    <item name="android:activityOpenExitAnimation">@anim/custom_out_curr</item>
    <item name="android:activityCloseEnterAnimation">@anim/custom_in_curr</item>
    <item name="android:activityCloseExitAnimation">@anim/custom_out_next</item>
</style>

###custom_in_next.xml

<?xml version="1.0" encoding="utf-8"?>

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

    <translate
            android:interpolator="@android:anim/accelerate_interpolator"
            android:fromXDelta="100%"
            android:toXDelta="0"
            android:duration="@android:integer/config_shortAnimTime"/>
</set>

###custom_out_curr.xml

<?xml version="1.0" encoding="utf-8"?>

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

    <translate
            android:duration="@android:integer/config_shortAnimTime"
            android:fromXDelta="0"
            android:interpolator="@android:anim/linear_interpolator"
            android:toXDelta="10%p" />

    <scale
            android:duration="200"
            android:fromXScale="1.0"
            android:fromYScale="1.0"
            android:interpolator="@android:anim/linear_interpolator"
            android:pivotX="50%"
            android:pivotY="50%"
            android:startOffset="100"
            android:toXScale=".95"
            android:toYScale=".95" />

    <alpha
            android:fromAlpha="1.0"
            android:toAlpha="0.5" />
</set>

###custom_in_curr.xml

<?xml version="1.0" encoding="utf-8"?>

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

    <translate
            android:interpolator="@android:anim/anticipate_overshoot_interpolator"
            android:fromXDelta="10%p"
            android:toXDelta="0"
            android:duration="@android:integer/config_shortAnimTime"/>

    <scale
            android:interpolator="@android:anim/anticipate_overshoot_interpolator"
            android:pivotX="0"
            android:pivotY="50%"
            android:fromXScale=".95"
            android:fromYScale=".95"
            android:toXScale="1.0"
            android:toYScale="1.0"
            android:startOffset="200"
            android:duration="@android:integer/config_shortAnimTime" />

    <alpha
            android:fromAlpha="0.5"
            android:toAlpha="1"/>
</set>

###custom_out_next.xml

<?xml version="1.0" encoding="utf-8"?>

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

    <translate
            android:interpolator="@android:anim/accelerate_interpolator"
            android:fromXDelta="0"
            android:toXDelta="100%p"
            android:duration="@android:integer/config_shortAnimTime" />
</set>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment