繁体   English   中英

如何使用Android P过渡动画

[英]How to use the Android P transition animation

我看到大量的应用程序为视图之间的过渡设置了动画效果,例如Android P设置应用程序中所做的那样。 我们该怎么做?

这是一个显示我的意思的视频: https : //youtu.be/FvrV0LBrau8

尝试这个-

1.将其添加到动画文件夹

bottom_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="1000"
        android:fromYDelta="90%"
        android:toYDelta="0" />
</set>

bottom_down.xml:

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="1500"
        android:fromYDelta="5"
        android:toYDelta="90%" />
</set>

没有.xml:

    <?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromYDelta="0%p"
    android:toYDelta="0%p" />

出售XActivity

    Intent intent = new Intent(MainActivity.this, XActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.bottom_up, R.anim.nothing);

现在完成XActivity

    @Override
public void onBackPressed() {
    super.onBackPressed();
    overridePendingTransition(R.anim.nothing, R.anim.bottom_down);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM