aboutsummaryrefslogtreecommitdiff
path: root/zh-cn/devices/tech/display/synched-app-transitions.html
blob: 2f0ef2af5a4843460806034d4887dca134506dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html devsite><head>

  <meta name="book_path" value="/_book.yaml"/>

  <meta name="project_path" value="/_project.yaml"/>
</head>
<body>

<!--
  Copyright 2018 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<h1 id="implementing_synchronized_app_transitions" class="page-title">实现同步应用转换</h1>

<p>同步应用转换是 Android 9 中的一项功能,可以改进现有的应用转换架构。当用户打开、关闭应用或在应用之间切换时,SystemUI 或启动器(主屏幕)进程会发送逐帧控制动画的请求,同时保证在视图动画和窗口动画之间进行同步。SystemUI 或启动器在动画过程中绘制新帧时,会在动画应用表面请求一个不同的转换,此转换可以确定应用在屏幕上的组成形式,并标记要与 SystemUI 或启动器目前正在绘制的帧同步的请求(表面事务)。</p>

<p>此过程可以实现无法在 Android 8.x 及更低版本中实现的新应用转换动画。例如,您可以通过<a href="/devices/tech/display/images/app-launch-animation.mp4">应用启动动画</a>将主屏幕图标无缝转换到应用表面,并可以通过<a href="/devices/tech/display/images/notification-launch-animation.mp4">通知启动动画</a>将通知转换到应用表面。</p>

<h2 id="examples_and_source">示例和来源</h2>

<p>请参阅以下参考来了解这项功能。</p>

<ul>
<li><p><a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/ActivityOptions.java"><code>ActivityOptions.makeRemoteAnimation</code></a></p></li>
<li><p><a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/"><code>RemoteAnimationAdapter</code></a></p></li>
<li><p><a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/"><code>RemoteAnimationRunner</code></a></p></li>
<li><p><a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/Activity.java#7869"><code>Activity.registerRemoteAnimations</code></a></p></li>
</ul>

<p>有关通知启动动画的参考实现,请参阅 <a href="https://android.googlesource.com/platform/frameworks/base/+/master/packages/SystemUI/src/com/android/systemui/statusbar/notification/"><code>ActivityLaunchAnimator.java</code></a>。</p>

<h2 id="implementation">实现</h2>

<p>您可以根据需要在启动器/系统界面上实现这项功能,也可以在 SystemUI/Launcher3 中使用 AOSP 实现。</p>
<aside class="note"><strong>注意</strong>:<span>这项功能会增加 GPU 和 CPU 在动画期间的负载。</span></aside>
<h2 id="validation">验证</h2>

<p>要验证动画效果,请衡量控制应用(即 SystemUI 或启动器)在动画期间的性能(如<a href="https://developer.android.com/training/testing/performance">测试界面性能</a>中所述)。</p>

</body></html>