public abstract class Transition
extends Object implements Cloneable
| java.lang.Object | |
| android.transition.Transition | |
| |
| |
过渡时间保存有关场景更改期间将在其目标上运行的动画的信息。 这个抽象类的子类可以编排几个子过渡( TransitionSet或者它们可以自己执行自定义动画。任何过渡都有两个主要工作:(1)捕获属性值,(2)根据对捕获的属性值的更改播放动画。转换知道View对象上的哪些属性值对其感兴趣,并且知道如何为这些值设置动画效果。例如, Fade转换跟踪与可见性相关的属性的更改,并能够构建并运行淡入淡出项目的动画或基于对这些属性的更改而退出。
注意:由于屏幕上显示这些视图的方式,转场可能无法正确使用SurfaceView或TextureView 。 对于SurfaceView,问题在于视图是从非UI线程更新的,所以由于转换(例如移动视图和调整视图大小)而导致视图更改可能与这些界限内的显示不同步。 TextureView与通常的转换更兼容,但是一些特定的转换(例如Fade )可能与TextureView不兼容,因为它们依赖于ViewOverlay功能,该功能目前不适用于TextureView。
可以在res/transition目录内的XML资源文件中声明转换。 过渡资源由一个Transition子类的标签名称和用于定义该过渡的一些属性的属性组成。 例如,这是一个声明ChangeBounds转换的最小资源文件:
<changeBounds/>
这TransitionSet包含 Explode能见度, ChangeBounds , ChangeTransform ,并 ChangeClipBounds和 ChangeImageTransform :
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<explode/>
<changeBounds/>
<changeTransform/>
<changeClipBounds/>
<changeImageTransform/>
</transitionSet>
自定义转换类可以使用 transition标签实例化:
<transition class="my.app.transition.CustomTransition"/>
从XML加载的自定义转换类应该有一个公共构造函数,其中包含 Context和 AttributeSet 。
请注意,不需要用于转换的属性,就像在代码中声明时一样,它们是可选的; 从XML资源创建的转换将使用与其代码创建的等价物相同的默认值。 这是一个稍微更复杂的例子,它声明了一个TransitionSet转换和ChangeBounds和Fade子转换:
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
android:transitionOrdering="sequential">
<changeBounds/>
<fade android:fadingMode="fade_out" >
<targets>
<target android:targetId="@id/grayscaleContainer" />
</targets>
</fade>
</transitionSet>
在此示例中,TransitionSet对象上使用的transitionOrdering属性将默认的ORDERING_TOGETHER行为更改为ORDERING_SEQUENTIAL 。 另外, Fade转换使用OUT的OUT而不使用默认的输出行为。 最后,要注意使用的targets子标签,它采用一组target标签,每个列出了具体targetId , targetClass , targetName , excludeId , excludeClass ,或excludeName ,此转变作用在。 目标的使用是可选的,但可用于限制检查不变视图上属性的时间,或者限制在特定视图上运行的动画类型。 在这种情况下,我们知道只有grayscaleContainer将会消失,所以我们选择将Fade转换限制为仅此视图。
Transition,
TransitionSet,
TransitionTarget,
Fade,
Slide, and
ChangeTransform.
Nested classes |
|
|---|---|
class |
Transition.EpicenterCallback 获得过渡中心的类。 |
interface |
Transition.TransitionListener 转换监听器接收来自转换的通知。 |
XML attributes |
|
|---|---|
android:duration |
Amount of time (in milliseconds) that the transition should run. |
android:interpolator |
Interpolator to be used in the animations spawned by this transition. |
android:startDelay |
Delay in milliseconds before the transition starts. |
常量(Constants) |
|
|---|---|
int |
MATCH_ID 与 |
int |
MATCH_INSTANCE 使用 |
int |
MATCH_ITEM_ID 与 |
int |
MATCH_NAME 与 |
Public constructors |
|
|---|---|
Transition() 构造一个没有目标对象的Transition对象。 |
|
Transition(Context context, AttributeSet attrs) 从XML执行通货膨胀并应用主题属性或样式资源中的特定于类的基本样式。 |
|
公共方法(Public methods) |
|
|---|---|
Transition |
addListener(Transition.TransitionListener listener) 将侦听器添加到通过动画生命周期发送事件的侦听器集,例如start,repeat和end。 |
Transition |
addTarget(View target) 设置此Transition对动画制作感兴趣的目标视图实例。 |
Transition |
addTarget(int targetId) 添加此Transition对动画感兴趣的目标视图的ID。 |
Transition |
addTarget(Class targetType) 添加此Transition对动画感兴趣的目标视图的Class。 |
Transition |
addTarget(String targetName) 添加此Transition对动画感兴趣的目标视图的transitionName。 |
boolean |
canRemoveViews() |
abstract void |
captureEndValues(TransitionValues transitionValues) 在结束场景中捕获此转换监视的属性的值。 |
abstract void |
captureStartValues(TransitionValues transitionValues) 捕获此转场监视的属性在开始场景中的值。 |
Transition |
clone() 创建并返回此对象的副本。 |
Animator |
createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) 此方法创建一个动画,该动画将为此转换运行,因为前面为start和end场景捕获的startValues和endValues结构中的信息。 |
Transition |
excludeChildren(int targetId, boolean exclude) 是否将给定ID的子项添加到要从此过渡中排除的目标列表。 |
Transition |
excludeChildren(Class type, boolean exclude) 是否将给定的类型添加到其子类应该从此转换中排除的类型的列表中。 |
Transition |
excludeChildren(View target, boolean exclude) 是否将给定目标的孩子添加到目标孩子的列表中以排除此过渡。 |
Transition |
excludeTarget(View target, boolean exclude) 是否将给定目标添加到要从此转换中排除的目标列表。 |
Transition |
excludeTarget(Class type, boolean exclude) 是否将给定类型添加到要从此过渡中排除的类型列表。 |
Transition |
excludeTarget(String targetName, boolean exclude) 是否将给定的transitionName添加到目标transitionNames的列表中以从此过渡中排除。 |
Transition |
excludeTarget(int targetId, boolean exclude) 是否将给定的ID添加到目标ID列表中以从此过渡中排除。 |
long |
getDuration() 返回在此转换中设置的持续时间。 |
Rect |
getEpicenter() 返回 |
Transition.EpicenterCallback |
getEpicenterCallback() 返回用于查找Transition的震中的回调。 |
TimeInterpolator |
getInterpolator() 返回此转换中的插补器集。 |
String |
getName() 返回此Transition的名称。 |
PathMotion |
getPathMotion() 返回用于沿着两个维度进行插值的算法对象。 |
TransitionPropagation |
getPropagation() 返回用于计算Animator启动延迟的 |
long |
getStartDelay() 返回此转换中设置的startDelay。 |
List<Integer> |
getTargetIds() 返回此转换将其自身限制为跟踪和动画的目标ID列表。 |
List<String> |
getTargetNames() 返回此转换将其自身限制为跟踪和动画的目标transitionNames的列表。 |
List<Class> |
getTargetTypes() 返回此转换将其自身限制为跟踪和动画的目标transitionNames的列表。 |
List<View> |
getTargets() 返回此转换将其自身限制为跟踪和动画的目标视图列表。 |
String[] |
getTransitionProperties() 返回存储在 |
TransitionValues |
getTransitionValues(View view, boolean start) 在转换播放过程中,可以通过转换来调用此方法以获取任何特定视图的TransitionValues。 |
boolean |
isTransitionRequired(TransitionValues startValues, TransitionValues endValues) 根据 |
Transition |
removeListener(Transition.TransitionListener listener) 从侦听此动画的集合中删除侦听器。 |
Transition |
removeTarget(int targetId) 从该Transition对动画感兴趣的id列表中移除给定的targetId。 |
Transition |
removeTarget(View target) 从该转换对动画感兴趣的目标列表中删除给定的目标。 |
Transition |
removeTarget(String targetName) 从Transition转换对动画感兴趣的transitionNames列表中删除给定的targetName。 |
Transition |
removeTarget(Class target) 从该转换对动画感兴趣的目标列表中删除给定的目标。 |
Transition |
setDuration(long duration) 设置此转换的持续时间。 |
void |
setEpicenterCallback(Transition.EpicenterCallback epicenterCallback) 设置回调以用于查找转场的震中。 |
Transition |
setInterpolator(TimeInterpolator interpolator) 设置此转换的插补器。 |
void |
setMatchOrder(int... matches) 设置Transition与View开始值和结束值的匹配顺序。 |
void |
setPathMotion(PathMotion pathMotion) 设置用于计算二维插值的算法。 |
void |
setPropagation(TransitionPropagation transitionPropagation) 设置确定动画制作者启动延迟的方法。 |
Transition |
setStartDelay(long startDelay) 设置此转换的startDelay。 |
String |
toString() 返回对象的字符串表示形式。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
应该运行转换的时间量(以毫秒为单位)。
必须是整数值,例如“ 100 ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 duration 。
相关方法:
Interpolator将用于此转换产生的动画。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 interpolator 。
相关方法:
转换开始之前的延迟时间(以毫秒为单位)。
必须是整数值,例如“ 100 ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 startDelay 。
相关方法:
int MATCH_ID
与setMatchOrder(int) ,选择匹配getId() 。 负号不会被匹配。
常量值:3(0x00000003)
int MATCH_INSTANCE
随着 setMatchOrder(int) ,选择由View实例匹配。
常数值:1(0x00000001)
int MATCH_ITEM_ID
随着setMatchOrder(int) ,选择匹配的Adapter项目编号。 当hasStableIds()返回false时,将不匹配项目。
常量值:4(0x00000004)
int MATCH_NAME
与setMatchOrder(int) ,选择匹配getTransitionName() 。 空名称不匹配。
常量值:2(0x00000002)
Transition ()
构造一个没有目标对象的Transition对象。 没有目标的转换默认为在场景层次结构中的所有目标对象上运行(如果转换不包含在TransitionSet中),或者所有目标对象从其父级传递(如果它位于TransitionSet中)。
Transition (Context context, AttributeSet attrs)
从XML执行通货膨胀并应用主题属性或样式资源中的特定于类的基本样式。 Transition的这个构造函数允许子类在膨胀时使用它们自己的基础样式。
| 参数(Parameters) | |
|---|---|
context |
Context: The Context the transition is running in, through which it can access the current theme, resources, etc. |
attrs |
AttributeSet: The attributes of the XML tag that is inflating the transition. |
Transition addListener (Transition.TransitionListener listener)
将侦听器添加到通过动画生命周期发送事件的侦听器集,例如start,repeat和end。
| 参数(Parameters) | |
|---|---|
listener |
Transition.TransitionListener: the listener to be added to the current set of listeners for this animation. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition addTarget (View target)
设置此Transition对动画制作感兴趣的目标视图实例。 默认情况下,没有目标,并且Transition将侦听场景的sceneRoot下面的每个视图的变化。 设定目标会限制转换只能监听并执行这些视图。 所有其他视图将被忽略。
目标列表与targetId列表类似,只是此列表指定了实际的View实例,而不是视图的ID。 当场景变化涉及单独膨胀的视图层次时,这是一个重要的区别; 不同的视图可以共享相同的ID,但实际上不是相同的实例。 如果过渡应该把这些意见相同,则addTarget(int)应该用来代替addTarget(View) 。 另一方面,如果场景变化涉及全部在相同视图层次内的变化,则在不一定具有对其设置ID的视图中,则目标视图列表可能更方便。
| 参数(Parameters) | |
|---|---|
target |
View: A View on which the Transition will act, must be non-null. |
| 返回(Returns) | |
|---|---|
Transition |
The Transition to which the target is added. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).addTarget(someView); |
也可以看看:
Transition addTarget (int targetId)
添加此Transition对动画感兴趣的目标视图的ID。 默认情况下,没有targetIds,并且Transition将侦听场景的sceneRoot下面的每个视图的变化。 设置targetIds会限制转换仅侦听并操作带有这些ID的视图。 具有不同ID的视图或任何ID都将被忽略。
请注意,使用ID指定目标意味着ID应该在场景根下的视图层次结构中是唯一的。
| 参数(Parameters) | |
|---|---|
targetId |
int: The id of a target view, must be a positive number. |
| 返回(Returns) | |
|---|---|
Transition |
The Transition to which the targetId is added. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).addTarget(someId); |
也可以看看:
Transition addTarget (Class targetType)
添加此Transition对动画感兴趣的目标视图的Class。 默认情况下,没有targetTypes,并且Transition将侦听场景的sceneRoot下面的每个视图的变化。 设置targetTypes会限制Transition仅侦听这些类并对其执行操作。 不同类别的视图将被忽略。
请注意,任何可以转换为targetType的视图都将包含在内,因此如果targetType为 View.class ,则将包含所有视图。
| 参数(Parameters) | |
|---|---|
targetType |
Class: The type to include when running this transition. |
| 返回(Returns) | |
|---|---|
Transition |
The Transition to which the target class was added. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).addTarget(ImageView.class); |
Transition addTarget (String targetName)
添加此Transition对动画感兴趣的目标视图的transitionName。 默认情况下,没有targetNames,Transition将侦听场景的sceneRoot下面的每个视图的变化。 设置targetNames会将转换限制为仅使用这些transitionNames来侦听和操作视图。 具有不同transitionNames的视图或任何transitionName都将被忽略。
请注意,transitionNames在视图层次结构中应该是唯一的。
| 参数(Parameters) | |
|---|---|
targetName |
String: The transitionName of a target view, must be non-null. |
| 返回(Returns) | |
|---|---|
Transition |
The Transition to which the target transitionName is added. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).addTarget(someName); |
也可以看看:
void captureEndValues (TransitionValues transitionValues)
在结束场景中捕获此转换监视的属性的值。 然后这些值作为endValues结构传递给createAnimator(ViewGroup, TransitionValues, TransitionValues) 。 实施的主要关注点是过渡期关注的属性以及所有这些属性的价值。 开始和结束值将在createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues)方法后期进行比较,以确定应该运行哪些动画(如果有的话)。
子类必须实现此方法。 该方法只能由过渡系统调用; 它不打算从外部类中调用。
| 参数(Parameters) | |
|---|---|
transitionValues |
TransitionValues: The holder for any values that the Transition wishes to store. Values are stored in the values field of this TransitionValues object and are keyed from a String value. For example, to store a view's rotation value, a transition might call transitionValues.values.put("appname:transitionname:rotation", view.getRotation()). The target view will already be stored in the transitionValues structure when this method is called. |
void captureStartValues (TransitionValues transitionValues)
捕获此转场监视的属性在开始场景中的值。 然后在稍后调用createAnimator(ViewGroup, TransitionValues, TransitionValues)将这些值作为startValues结构createAnimator(ViewGroup, TransitionValues, TransitionValues) 。 实施的主要关注点是过渡期关注的属性以及所有这些属性的价值。 开始和结束值将在createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues)方法后期进行比较,以确定应该运行哪些动画(如果有的话)。
子类必须实现此方法。 该方法只能由过渡系统调用; 它不打算从外部类中调用。
| 参数(Parameters) | |
|---|---|
transitionValues |
TransitionValues: The holder for any values that the Transition wishes to store. Values are stored in the values field of this TransitionValues object and are keyed from a String value. For example, to store a view's rotation value, a transition might call transitionValues.values.put("appname:transitionname:rotation", view.getRotation()). The target view will already be stored in the transitionValues structure when this method is called. |
Transition clone ()
创建并返回此对象的副本。 “复制”的确切含义可能取决于对象的类别。 一般意图是,对于任何对象x ,表达式:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements. While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
按照惯例,应该通过调用super.clone获得返回的对象。 如果一个类和它的所有超类(除了Object )都遵守这个约定,那么情况就是这样的情况x.clone().getClass() == x.getClass() 。
按照惯例,这个方法返回的对象应该独立于这个对象(被克隆)。 为了实现这种独立性,可能需要在返回super.clone之前修改对象的一个或多个字段。 通常,这意味着复制包含被克隆对象的内部“深层结构”的任何可变对象,并将这些对象的引用替换为对这些副本的引用。 如果一个类只包含原始字段或对不可变对象的引用,那么通常情况下不需要修改super.clone返回的对象中的任何字段。
类别Object的方法clone执行特定的克隆操作。 首先,如果该对象的类没有实现接口Cloneable ,则引发CloneNotSupportedException 。 请注意,所有数组都被认为实现了接口Cloneable并且数组类型T[]的clone方法的返回类型为T[] ,其中T是任何引用或基本类型。 否则,此方法创建该对象的类的新实例,并使用该对象的相应字段的内容来初始化其所有字段,就像通过赋值一样; 这些字段的内容本身并不克隆。 因此,此方法执行此对象的“浅拷贝”,而不是“深拷贝”操作。
类 Object本身并不实现接口 Cloneable ,所以在类 Object的对象上调用 clone方法将导致在运行时抛出异常。
| 返回(Returns) | |
|---|---|
Transition |
a clone of this instance. |
Animator createAnimator (ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues)
此方法创建一个动画,该动画将为此转换运行,因为前面为start和end场景捕获的startValues和endValues结构中的信息。 Transition的子类应该覆盖此方法。 该方法只能由过渡系统调用; 它不打算从外部类中调用。
该方法由transition的父级(一直到层次结构中最高级的Transition)调用,并使用sceneRoot和start / end值进行调用,以便转换可能需要设置初始目标值并构建适当的动画。 例如,如果总体Transition是由几个子级转换组成的TransitionSet ,则一些子级转换可能希望在整个Transition转换开始之前在目标视图上设置初始值,以使其处于延迟的适当状态在开始和孩子之间的过渡开始时间。 例如,淡入一个项目的转换可能希望将开始的alpha值设置为0,以避免在实际开始动画之前的转换之前其闪烁。 这是必要的,因为触发Transition的场景变化将自动设置所有目标视图上的结束场景,因此想要从不同值开始动画的Transition应该在从此方法返回之前设置该值。
另外,Transition可以执行逻辑来确定是否需要在给定目标上运行转换以及开始/结束值。 例如,调整屏幕上对象大小的过渡可能希望避免在开始场景或结束场景中不存在的视图运行。
如果有一个动画创建并从这个方法返回,转换机制会将任何适用的持续时间,startDelay和插补器应用到该动画并启动它。 返回值null表示不应该运行动画。 默认实现返回null。
该方法针对每个可应用的目标对象进行调用,该对象存储在 view字段中。
| 参数(Parameters) | |
|---|---|
sceneRoot |
ViewGroup: The root of the transition hierarchy. |
startValues |
TransitionValues: The values for a specific target in the start scene. |
endValues |
TransitionValues: The values for the target in the end scene. |
| 返回(Returns) | |
|---|---|
Animator |
A Animator to be started at the appropriate time in the overall transition for this scene change. A null value means no animation should be run. |
Transition excludeChildren (int targetId, boolean exclude)
是否将给定ID的子项添加到要从此过渡中排除的目标列表。 exclude参数指定是否应将目标的子项添加到排除列表或从排除列表中删除。 以这种方式排除儿童提供了一种排除所有具体目标儿童的简单机制,而不是单独排除每个儿童。
排除目标是允许转换在视图层次结构上运行同时跳过不应该成为转换部分的目标视图的一般机制。 例如,您可能希望避免为特定ListView或Spinner的子项设置动画。 视图可以通过它们的id,或它们的实例引用或该视图的Class(例如, Spinner ) Spinner 。
| 参数(Parameters) | |
|---|---|
targetId |
int: The id of a target whose children should be ignored when running this transition. |
exclude |
boolean: Whether to add the target to or remove the target from the current list of excluded-child targets. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition excludeChildren (Class type, boolean exclude)
是否将给定的类型添加到其子类应该从此转换中排除的类型的列表中。 exclude参数指定是否应将目标类型添加到排除列表或从排除列表中删除。
排除目标是允许转换在视图层次结构上运行同时跳过不应该成为转换部分的目标视图的一般机制。 例如,您可能希望避免为特定ListView或Spinner的子项设置动画。 视图可以通过它们的id,或它们的实例引用,或该视图的Class(例如, Spinner ) Spinner 。
| 参数(Parameters) | |
|---|---|
type |
Class: The type to ignore when running this transition. |
exclude |
boolean: Whether to add the target type to or remove it from the current list of excluded target types. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition excludeChildren (View target, boolean exclude)
是否将给定目标的孩子添加到目标孩子的列表中以排除此过渡。 exclude参数指定是否应将目标添加到排除列表或从排除列表中删除。
Excluding targets is a general mechanism for allowing transitions to run on a view hierarchy while skipping target views that should not be part of the transition. For example, you may want to avoid animating children of a specific ListView or Spinner. Views can be excluded either by their id, or by their instance reference, or by the Class of that view (eg, Spinner).
| 参数(Parameters) | |
|---|---|
target |
View: The target to ignore when running this transition. |
exclude |
boolean: Whether to add the target to or remove the target from the current list of excluded targets. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition excludeTarget (View target, boolean exclude)
是否将给定目标添加到要从此转换中排除的目标列表。 参数exclude指定是否应将目标添加到排除列表或从排除列表中删除。
Excluding targets is a general mechanism for allowing transitions to run on a view hierarchy while skipping target views that should not be part of the transition. For example, you may want to avoid animating children of a specific ListView or Spinner. Views can be excluded either by their id, or by their instance reference, or by the Class of that view (eg, Spinner).
| 参数(Parameters) | |
|---|---|
target |
View: The target to ignore when running this transition. |
exclude |
boolean: Whether to add the target to or remove the target from the current list of excluded targets. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition excludeTarget (Class type, boolean exclude)
是否将给定类型添加到要从此过渡中排除的类型列表。 exclude参数指定是否应将目标类型添加到排除列表或从排除列表中删除。
排除目标是允许转换在视图层次结构上运行同时跳过不应该成为转换部分的目标视图的一般机制。 例如,您可能希望避免为特定ListView或Spinner的子项设置动画。 视图可以通过它们的id,或它们的实例引用或该视图的Class(例如, Spinner ) Spinner 。
| 参数(Parameters) | |
|---|---|
type |
Class: The type to ignore when running this transition. |
exclude |
boolean: Whether to add the target type to or remove it from the current list of excluded target types. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition excludeTarget (String targetName, boolean exclude)
是否将给定的transitionName添加到目标transitionNames的列表中以从此过渡中排除。 exclude参数指定是否应将目标添加到排除列表或从排除列表中删除。
排除目标是允许转换在视图层次结构上运行同时跳过不应该成为转换部分的目标视图的一般机制。 例如,您可能希望避免为特定ListView或Spinner的子项设置动画。 视图可以通过它们的id,它们的实例引用,它们的transitionName或者视图的Class(例如Spinner ) Spinner 。
| 参数(Parameters) | |
|---|---|
targetName |
String: The name of a target to ignore when running this transition. |
exclude |
boolean: Whether to add the target to or remove the target from the current list of excluded targets. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition excludeTarget (int targetId, boolean exclude)
是否将给定的ID添加到目标ID列表中以从此过渡中排除。 参数exclude指定是否应将目标添加到排除列表或从排除列表中删除。
排除目标是允许转换在视图层次结构上运行同时跳过不应该成为转换部分的目标视图的一般机制。 例如,您可能希望避免为特定ListView或Spinner的子项设置动画。 视图可以通过它们的id或其实例引用或该视图的Class(例如Spinner ) Spinner 。
| 参数(Parameters) | |
|---|---|
targetId |
int: The id of a target to ignore when running this transition. |
exclude |
boolean: Whether to add the target to or remove the target from the current list of excluded targets. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
long getDuration ()
返回在此转换中设置的持续时间。 如果没有设置持续时间,返回值将为负值,表示动画师将保留自己的持续时间。
| 返回(Returns) | |
|---|---|
long |
The duration set on this transition, in milliseconds, if one has been set, otherwise returns a negative number. |
Rect getEpicenter ()
返回 Transition.EpicenterCallback指定的震中,如果不存在回调,则 Transition.EpicenterCallback null。
| 返回(Returns) | |
|---|---|
Rect |
the epicenter as specified by the Transition.EpicenterCallback or null if no callback exists. |
Transition.EpicenterCallback getEpicenterCallback ()
返回用于查找Transition的震中的回调。 诸如Explode类的Explode使用点或Rect来定位行进方向。 这被称为过渡的中心,通常集中在一个触摸的视图。 Transition.EpicenterCallback允许一个转换动态检索过渡期间的震中。
| 返回(Returns) | |
|---|---|
Transition.EpicenterCallback |
the callback used to find the epicenter of the Transition. |
TimeInterpolator getInterpolator ()
返回此转换中的插补器集。 如果未设置插补器,则返回的值将为空,表示动画师将保留自己的插补器。
| 返回(Returns) | |
|---|---|
TimeInterpolator |
The interpolator set on this transition, if one has been set, otherwise returns null. |
String getName ()
返回此Transition的名称。 该名称在内部用于区分不同的转换以确定何时中断转换重叠。 例如,与另一个ChangeBounds在同一个目标视图上运行的ChangeBounds应确定旧的过渡是否动画到不同的最终值,并且应该取消以支持新的过渡。
默认情况下,Transition的名称只是 getName()的值,但子类可以自由覆盖并返回不同的内容。
| 返回(Returns) | |
|---|---|
String |
The name of this transition. |
PathMotion getPathMotion ()
返回用于沿着两个维度进行插值的算法对象。 这通常用于确定两点之间的视图运动。
在用XML描述时,为路径运动使用嵌套的XML标记。 它可以是内置标签arcMotion或patternPathMotion ,也可以是使用pathMotion的定制PathMotion, class归因于完全描述的类名称。 例如:
<changeBounds>
<pathMotion class="my.app.transition.MyPathMotion"/>
</changeBounds>
要么
<changeBounds>
<arcMotion android:minimumHorizontalAngle="15"
android:minimumVerticalAngle="0"
android:maximumAngle="90"/>
</changeBounds>
| 返回(Returns) | |
|---|---|
PathMotion |
The algorithm object used to interpolate along two dimensions. |
也可以看看:
TransitionPropagation getPropagation ()
返回用于计算Animator启动延迟的TransitionPropagation 。 当一个转换影响像Explode或Slide这样的几个视图时,可能需要有一个“波前”效应,这样动画开始延迟取决于视图的位置。 TransitionPropagation指定如何计算启动延迟。
| 返回(Returns) | |
|---|---|
TransitionPropagation |
the TransitionPropagation used to calculate Animator start delays. This is null by default. |
long getStartDelay ()
返回此转换中设置的startDelay。 如果没有设置startDelay,则返回的值将为负值,表示生成的动画人员将保留自己的startDelay。
| 返回(Returns) | |
|---|---|
long |
The startDelay set on this transition, in milliseconds, if one has been set, otherwise returns a negative number. |
List<Integer> getTargetIds ()
返回此转换将其自身限制为跟踪和动画的目标ID列表。 如果列表为空或为空getTargetIds() , getTargets() , getTargetNames() ,并getTargetTypes()那么这种转变并不限于特定的意见,并将处理变化的场景变化的层次结构的任何意见。
| 返回(Returns) | |
|---|---|
List<Integer> |
the list of target IDs |
List<String> getTargetNames ()
返回此转换将其自身限制为跟踪和动画的目标transitionNames的列表。 如果列表为空或为空getTargetIds() , getTargets() , getTargetNames() ,并getTargetTypes()那么这种转变并不限于特定的意见,并将处理变化的场景变化的层次结构的任何意见。
| 返回(Returns) | |
|---|---|
List<String> |
the list of target transitionNames |
List<Class> getTargetTypes ()
返回此转换将其自身限制为跟踪和动画的目标transitionNames的列表。 如果列表为空或为空getTargetIds() , getTargets() , getTargetNames() ,并getTargetTypes()那么这种转变并不限于特定的意见,并将处理变化的场景变化的层次结构的任何意见。
| 返回(Returns) | |
|---|---|
List<Class> |
the list of target Types |
List<View> getTargets ()
返回此转换将其自身限制为跟踪和动画的目标视图列表。 如果列表为空或为空getTargetIds() , getTargets() , getTargetNames() ,并getTargetTypes()那么这种转变并不限于特定的意见,并将处理变化的场景变化的层次结构的任何意见。
| 返回(Returns) | |
|---|---|
List<View> |
the list of target views |
String[] getTransitionProperties ()
返回存储在传递到TransitionValues对象中的属性名称captureStartValues(TransitionValues) ,此对象用于取消重叠动画。 当在给定场景根上开始任何转场时,将检查当前在同一场景根上运行的所有转场,以查看它们基于其动画的属性是否与新转场中相同属性的最终值一致。 如果最终值不相等,则旧的动画将被取消,因为新的转换将为这些新值开始新的动画。 如果值相等,则允许旧动画继续,并且不会为该转换启动新的动画。
过渡不需要重写此方法。 但是,如果不这样做,则意味着上一段中所述的取消逻辑将跳过该转换,可能会导致人为因素,因为旧转换和同一目标上的新转换并行运行,将视图动画化为可能不同的最终值。
| 返回(Returns) | |
|---|---|
String[] |
An array of property names as described in the class documentation for TransitionValues. The default implementation returns null. |
TransitionValues getTransitionValues (View view, boolean start)
在转换播放过程中,可以通过转换来调用此方法以获取任何特定视图的TransitionValues。 例如,这可能是必要的,以查询给定转换的相关视图的前/后状态。
| 参数(Parameters) | |
|---|---|
view |
View
|
start |
boolean
|
| 返回(Returns) | |
|---|---|
TransitionValues |
|
boolean isTransitionRequired (TransitionValues startValues, TransitionValues endValues)
基于captureStartValues(TransitionValues)和captureEndValues(TransitionValues)期间捕获的值,返回过渡是否应创建Animator。 默认实现比较从getTransitionProperties()返回的属性值,或者如果getTransitionProperties()返回null,则返回所有属性值。 子类可以重写此方法来为转换实现提供更具体的逻辑。
| 参数(Parameters) | |
|---|---|
startValues |
TransitionValues: the values from captureStartValues, This may be null if the View did not exist in the start state. |
endValues |
TransitionValues: the values from captureEndValues. This may be null if the View did not exist in the end state. |
| 返回(Returns) | |
|---|---|
boolean |
|
Transition removeListener (Transition.TransitionListener listener)
从侦听此动画的集合中删除侦听器。
| 参数(Parameters) | |
|---|---|
listener |
Transition.TransitionListener: the listener to be removed from the current set of listeners for this transition. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
Transition removeTarget (int targetId)
从该Transition对动画感兴趣的id列表中移除给定的targetId。
| 参数(Parameters) | |
|---|---|
targetId |
int: The id of a target view, must be a positive number. |
| 返回(Returns) | |
|---|---|
Transition |
The Transition from which the targetId is removed. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).removeTargetId(someId); |
Transition removeTarget (View target)
从该转换对动画感兴趣的目标列表中删除给定的目标。
| 参数(Parameters) | |
|---|---|
target |
View: The target view, must be non-null. |
| 返回(Returns) | |
|---|---|
Transition |
Transition The Transition from which the target is removed. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).removeTarget(someView); |
Transition removeTarget (String targetName)
从Transition转换对动画感兴趣的transitionNames列表中删除给定的targetName。
| 参数(Parameters) | |
|---|---|
targetName |
String: The transitionName of a target view, must not be null. |
| 返回(Returns) | |
|---|---|
Transition |
The Transition from which the targetName is removed. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).removeTargetName(someName); |
Transition removeTarget (Class target)
从该转换对动画感兴趣的目标列表中删除给定的目标。
| 参数(Parameters) | |
|---|---|
target |
Class: The type of the target view, must be non-null. |
| 返回(Returns) | |
|---|---|
Transition |
Transition The Transition from which the target is removed. Returning the same object makes it easier to chain calls during construction, such as transitionSet.addTransitions(new Fade()).removeTarget(someType); |
Transition setDuration (long duration)
设置此转换的持续时间。 默认情况下,没有持续时间(由负数表示),这意味着由过渡创建的动画制作者将拥有自己的指定持续时间。 如果设置了过渡的持续时间,则该持续时间将覆盖动画持续时间。
相关XML属性:
| 参数(Parameters) | |
|---|---|
duration |
long: The length of the animation, in milliseconds. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
void setEpicenterCallback (Transition.EpicenterCallback epicenterCallback)
设置回调以用于查找转场的震中。 空值表示Transition中没有震中,onGetEpicenter()将返回null。 诸如Explode类的Explode使用一个点或Rect来定位行进方向。 这被称为过渡的中心,通常集中在一个触摸的视图。 Transition.EpicenterCallback允许转换在转换期间动态检索震中。
| 参数(Parameters) | |
|---|---|
epicenterCallback |
Transition.EpicenterCallback: The callback to use to find the epicenter of the Transition. |
Transition setInterpolator (TimeInterpolator interpolator)
设置此转换的插补器。 默认情况下,插补器为空,这意味着由转换创建的Animator将拥有自己的指定插补器。 如果设置了Transition的插补器,则该插补器将覆盖Animator插补器。
相关XML属性:
| 参数(Parameters) | |
|---|---|
interpolator |
TimeInterpolator: The time interpolator used by the transition |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
void setMatchOrder (int... matches)
设置Transition与View开始值和结束值的匹配顺序。
默认行为是通过首先匹配getTransitionName() ,然后通过查看实例,然后通过getId()其项目编号以及最后如果是在ListView控件的直接子。 来电者只能选择有一些或全部的值MATCH_INSTANCE , MATCH_NAME , MATCH_ITEM_ID ,并MATCH_ID 。 只有提供的匹配算法才会用于确定视图在开始场景和结束场景中是否相同。 不匹配的视图将被视为进入或离开场景。
| 参数(Parameters) | |
|---|---|
matches |
int: A list of zero or more of MATCH_INSTANCE, MATCH_NAME, MATCH_ITEM_ID, and MATCH_ID. If none are provided, then the default match order will be set. |
void setPathMotion (PathMotion pathMotion)
设置用于计算二维插值的算法。
诸如ChangeBounds转ChangeBounds移动视图,通常位于起始位置和结束位置之间的直线路径中。 希望让这些运动以曲线形式移动的应用程序可以通过扩展PathMotion并实现getPath(float, float, float, float)来改变View在二维中的内插getPath(float, float, float, float) 。
在用XML描述时,为路径运动使用嵌套的XML标记。 它可以是内置标签arcMotion或patternPathMotion ,也可以是使用pathMotion的自定义PathMotion, class属于完全描述的类名称。 例如:
<changeBounds>
<pathMotion class="my.app.transition.MyPathMotion"/>
</changeBounds>
要么
<changeBounds>
<arcMotion android:minimumHorizontalAngle="15"
android:minimumVerticalAngle="0" android:maximumAngle="90"/>
</changeBounds>
| 参数(Parameters) | |
|---|---|
pathMotion |
PathMotion: Algorithm object to use for determining how to interpolate in two dimensions. If null, a straight-path algorithm will be used. |
也可以看看:
void setPropagation (TransitionPropagation transitionPropagation)
设置确定动画制作者启动延迟的方法。 当过渡影响像Explode或Slide这样的几个视图时,可能需要产生“波前”效应,以使动画开始延迟取决于视图的位置。 TransitionPropagation指定如何计算启动延迟。
| 参数(Parameters) | |
|---|---|
transitionPropagation |
TransitionPropagation: The class used to determine the start delay of Animators created by this Transition. A null value indicates that no delay should be used. |
Transition setStartDelay (long startDelay)
设置此转换的startDelay。 默认情况下,没有延迟(由负数表示),这意味着由过渡创建的Animator将拥有自己的指定startDelay。 如果设置了延迟时间,则延迟将覆盖Animator延迟。
相关XML属性:
| 参数(Parameters) | |
|---|---|
startDelay |
long: The length of the delay, in milliseconds. |
| 返回(Returns) | |
|---|---|
Transition |
This transition object. |
String toString ()
返回对象的字符串表示形式。 通常, toString方法返回一个“文本表示”该对象的字符串。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。
toString类的方法Object返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示。 换句话说,这个方法返回一个字符串,其值等于:
getClass().getName() + '@' + Integer.toHexString(hashCode())
| 返回(Returns) | |
|---|---|
String |
a string representation of the object. |