【问题标题】:How to use the Android P transition animation如何使用Android P过渡动画
【发布时间】:2018-09-06 09:27:42
【问题描述】:

我看到很多应用程序动画视图之间的过渡,例如在Android P 设置应用程序。我们如何做到这一点?

这里有一段视频说明我的意思:https://youtu.be/FvrV0LBrau8

【问题讨论】:

  • 如果你用谷歌搜索“Activity Transitions”,你会发现很多资源,甚至是官方资源。从那里开始。另外,转到开发人员设置并减慢过渡动画速度。这将帮助您更好地了解动画的作用。
  • 这种特殊的过渡甚至不适用于跨活动的视图,因此它应该相当简单。见developer.android.com/reference/android/app/…
  • @EugenPechanec 当然,我对动画并不陌生。我只是想也许这个特定动画有一个标准 api,因为一旦我更新到 Android P,很多应用程序都有它。也许我的问题应该更好地传达这一点。

标签: android android-animation android-transitions android-9.0-pie


【解决方案1】:

试试这个-

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>

nothing.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);
}

【讨论】:

  • 这不是同一个动画,如果你放慢速度,你会看到内容从 0% 到 100% 被剪辑,它只在结束时将内容从 90% 转换到 100%动画
  • 这太丑了不是活动过渡
猜你喜欢
  • 1970-01-01
  • 2018-07-10
  • 2013-02-11
  • 1970-01-01
  • 2015-05-07
  • 1970-01-01
  • 2015-05-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多