0

Android 页面左右切换动画实现

slide_left_in.xml

<?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”http://schemas.android.com/apk/res/android”> <translate android:duration=”300″ android:fromXDelta=”-100.0%p” android:toXDelta=”0.0″ /> </set>

slide_left_out.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<set
xmlns:android=”http://schemas.android.com/apk/res/android”>
<translate android:duration=”300″ android:fromXDelta=”0.0″ android:toXDelta=”-100.0%p” />
</set>
slide_right_in.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<set
xmlns:android=”http://schemas.android.com/apk/res/android”>
<translate android:duration=”300″ android:fromXDelta=”100.0%p” android:toXDelta=”0.0″ />
</set>

slide_right_out.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<set
xmlns:android=”http://schemas.android.com/apk/res/android”>
<translate android:duration=”300″ android:fromXDelta=”0.0″ android:toXDelta=”100.0%p” />
</set>

1. 在Style文件里面定义

    <style name=”AppTheme” parent=”@android:style/Theme.Black.NoTitleBar.Fullscreen”>
<item name=”android:windowNoTitle”>true</item>
<!– 设置activity切换动画 –>
<item name=”android:windowAnimationStyle”>@style/activityAnimation</item>
</style>

    <!– animation 样式 –>
<style name=”activityAnimation” parent=”@android:style/Animation”>
<item name=”android:activityOpenEnterAnimation”>@anim/slide_right_in</item>
<item name=”android:activityOpenExitAnimation”>@anim/slide_left_out</item>
<item name=”android:activityCloseEnterAnimation”>@anim/slide_left_in</item>
<item name=”android:activityCloseExitAnimation”>@anim/slide_right_out</item>
</style>

2.在Manifest里面application设置Theme   android:theme=”@style/AppTheme”

天边的星星