【问题标题】:Z-order changed in activity transition animations on android 7.0 (nougat)?android 7.0(牛轧糖)上的活动过渡动画的 Z 顺序发生了变化?
【发布时间】:2016-09-19 22:17:46
【问题描述】:

我为 onBackPressed 使用自定义动画

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

在 Android 6.x 上,退出转换具有最高的 z 顺序,这意味着我可以将离开的活动滑出,而“新”活动在其下方放大。 Marshmallow 上一切正常,但在 Android 7.0 上 z-order 颠倒了。

还有其他人遇到这种情况吗?

有什么修复建议吗?

【问题讨论】:

    标签: android android-7.0-nougat


    【解决方案1】:

    问题的解决方法是在动画xml中添加android:zAdjustment="...":

    <set xmlns:android="http://schemas.android.com/apk/res/android"
         ...
         android:zAdjustment="top">
    

    <set xmlns:android="http://schemas.android.com/apk/res/android"
         ...
         android:zAdjustment="bottom">
    

    到另一个动画。

    注意:有时我需要重新构建项目才能看到动画的变化。

    【讨论】:

    • 这个解决方案有可能在 API 28 以上的某个地方被破坏了吗?无法让它在我的模拟器上运行。无论我做什么,进入的活动都会显示在退出的活动之上。
    • 很有可能。很久以前我测试过这个:)
    • 抱歉打扰了,我已经解决了。我错误地将属性放在Translate 动画而不是外部set
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多