Android 页面跳转动画

动画的xml文件

push_in.xml

<translate
    android:duration="300"
    android:fromYDelta="100%p"
    android:toYDelta="0" />

 push_out.xml

<translate
    android:duration="300"
    android:fromYDelta="0"
    android:toYDelta="100%p" />

第一种:overridePendingTransition

打开  A->B  (push_bottom_in B的动画,no_animation A的无动画)

startActivity(LoginActivity.class);
overridePendingTransition(R.anim.push_bottom_in, R.anim.no_animation);

关闭 B->A(push_bottom_out B的动画,no_animation A的无动画)

finish();
overridePendingTransition(R.anim.no_animation, R.anim.push_bottom_out);

无动画的设置

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

  android:fromYDelta="0"

  android:toXDelta="0"

  android:duration="1000"/>

扫描二维码关注公众号,回复: 5083126 查看本文章

2.调用overridePendingTransition(enterAnim, exitAnim)时,enterAnim和exitAnim如果有为0的值,指的是不设置该动画。

 第二种,设置activity的主题,theme

<!--登录画面动画-->
<style name="LoginActivityStyle" parent="@android:style/Animation">
    <item name="android:windowEnterAnimation">@anim/push_bottom_in</item>
    <item name="android:windowExitAnimation">@anim/push_bottom_out</item>
</style>


<style name="Loginanimation" parent="AppTheme">
    <item name="android:windowAnimationStyle">@style/LoginActivityStyle</item>
</style>

在manifest

android:theme="@style/Loginanimation"

猜你喜欢

转载自blog.csdn.net/qq_30711091/article/details/86512216