开源直播系统源码Android中activity跳转动画效果

1.res-anim中添加文件
(1)dialog_left_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="400"
        android:fromXDelta="-100%p" />
</set>

(2)push_left_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<translate android:fromXDelta="0" android:toXDelta="100%p"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
		android:duration="300" />
</set>

(3)push_right_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="100%" android:toXDelta="0"
               android:interpolator="@android:anim/accelerate_decelerate_interpolator"
               android:duration="300" />
</set>

(4)push_right_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="-100%"
               android:interpolator="@android:anim/accelerate_decelerate_interpolator"
               android:duration="300" />
</set>

2.res—style中添加style

<!--页面跳转动画-->
<style name="ActivityStyle">
    <item name="@android:activityOpenEnterAnimation">@anim/push_right_in</item>
    <item name="@android:activityOpenExitAnimation">@anim/push_right_out</item>
    <item name="@android:activityCloseEnterAnimation">@anim/dialog_left_in</item>
    <item name="@android:activityCloseExitAnimation">@anim/push_left_out</item>
</style>

3.在自己的style中引用ActivityStyle

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

你可能感兴趣的:(技术类,android,apk,移动开发,安卓,app)