IT. Expert System.

Android Reference

Animation


android.view.animation

Class Animation

    • Nested Class Summary

      Nested Classes
      Modifier and Type Class and Description
      static interface Animation.AnimationListener
      An animation listener receives notifications from an animation.
      protected static class Animation.Description
      Utility class to parse a string description of a size.
    • Field Summary

      Fields
      Modifier and Type Field and Description
      static int ABSOLUTE
      The specified dimension is an absolute number of pixels.
      static int INFINITE
      Repeat the animation indefinitely.
      static int RELATIVE_TO_PARENT
      The specified dimension holds a float and should be multiplied by the height or width of the parent of the object being animated.
      static int RELATIVE_TO_SELF
      The specified dimension holds a float and should be multiplied by the height or width of the object being animated.
      static int RESTART
      When the animation reaches the end and the repeat count is INFINTE_REPEAT or a positive value, the animation restarts from the beginning.
      static int REVERSE
      When the animation reaches the end and the repeat count is INFINTE_REPEAT or a positive value, the animation plays backward (and then forward again).
      static int START_ON_FIRST_FRAME
      Can be used as the start time to indicate the start time should be the current time when getTransformation(long, Transformation) is invoked for the first animation frame.
      static int ZORDER_BOTTOM
      Requests that the content being animated be forced under all other content for the duration of the animation.
      static int ZORDER_NORMAL
      Requests that the content being animated be kept in its current Z order.
      static int ZORDER_TOP
      Requests that the content being animated be forced on top of all other content for the duration of the animation.
    • Constructor Summary

      Constructors
      Constructor and Description
      Animation()
      Creates a new animation with a duration of 0ms, the default interpolator, with fillBefore set to true and fillAfter set to false
      Animation(Context context, AttributeSet attrs)
      Creates a new animation whose parameters come from the specified context and attributes set.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      protected void applyTransformation(float interpolatedTime, Transformation t)
      Helper for getTransformation.
      void cancel()
      Cancel the animation.
      protected Animation clone()
      Creates and returns a copy of this Object.
      long computeDurationHint()
      Compute a hint at how long the entire animation may last, in milliseconds.
      void detach()
      protected void ensureInterpolator()
      Gurantees that this animation has an interpolator.
      protected void finalize()
      Invoked when the garbage collector has detected that this instance is no longer reachable.
      int getBackgroundColor()
      Returns the background color behind the animation.
      boolean getDetachWallpaper()
      long getDuration()
      How long this animation should last
      boolean getFillAfter()
      If fillAfter is true, this animation will apply its transformation after the end time of the animation.
      boolean getFillBefore()
      If fillBefore is true, this animation will apply its transformation before the start time of the animation.
      Interpolator getInterpolator()
      Gets the acceleration curve type for this animation.
      void getInvalidateRegion(int left, int top, int right, int bottom, RectF invalidate, Transformation transformation)
      int getRepeatCount()
      Defines how many times the animation should repeat.
      int getRepeatMode()
      Defines what this animation should do when it reaches the end.
      protected float getScaleFactor()
      The scale factor is set by the call to getTransformation.
      long getStartOffset()
      When this animation should start, relative to StartTime
      long getStartTime()
      When this animation should start.
      boolean getTransformation(long currentTime, Transformation outTransformation)
      Gets the transformation to apply at a specified point in time.
      boolean getTransformation(long currentTime, Transformation outTransformation, float scale)
      Gets the transformation to apply at a specified point in time.
      int getZAdjustment()
      Returns the Z ordering mode to use while running the animation as previously set by setZAdjustment(int).
      boolean hasAlpha()
      Return true if this animation changes the view's alpha property.
      boolean hasEnded()
      Indicates whether this animation has ended or not.
      boolean hasStarted()
      Indicates whether this animation has started or not.
      void initialize(int width, int height, int parentWidth, int parentHeight)
      Initialize this animation with the dimensions of the object being animated as well as the objects parents.
      void initializeInvalidateRegion(int left, int top, int right, int bottom)
      boolean isFillEnabled()
      If fillEnabled is true, this animation will apply the value of fillBefore.
      boolean isInitialized()
      Whether or not the animation has been initialized.
      void reset()
      Reset the initialization state of this animation.
      protected float resolveSize(int type, float value, int size, int parentSize)
      Convert the information in the description of a size to an actual dimension
      void restrictDuration(long durationMillis)
      Ensure that the duration that this animation will run is not longer than durationMillis.
      void scaleCurrentDuration(float scale)
      How much to scale the duration by.
      void setAnimationListener(Animation.AnimationListener listener)
      Binds an animation listener to this animation.
      void setBackgroundColor(int bg)
      Set background behind animation.
      void setDetachWallpaper(boolean detachWallpaper)
      If detachWallpaper is true, and this is a window animation of a window that has a wallpaper background, then the window will be detached from the wallpaper while it runs.
      void setDuration(long durationMillis)
      How long this animation should last.
      void setFillAfter(boolean fillAfter)
      If fillAfter is true, the transformation that this animation performed will persist when it is finished.
      void setFillBefore(boolean fillBefore)
      If fillBefore is true, this animation will apply its transformation before the start time of the animation.
      void setFillEnabled(boolean fillEnabled)
      If fillEnabled is true, the animation will apply the value of fillBefore.
      void setInterpolator(Context context, int resID)
      Sets the acceleration curve for this animation.
      void setInterpolator(Interpolator i)
      Sets the acceleration curve for this animation.
      void setListenerHandler(Handler handler)
      Sets the handler used to invoke listeners.
      void setRepeatCount(int repeatCount)
      Sets how many times the animation should be repeated.
      void setRepeatMode(int repeatMode)
      Defines what this animation should do when it reaches the end.
      void setStartOffset(long startOffset)
      When this animation should start relative to the start time.
      void setStartTime(long startTimeMillis)
      When this animation should start.
      void setZAdjustment(int zAdjustment)
      Set the Z ordering mode to use while running the animation.
      void start()
      Convenience method to start the animation the first time getTransformation(long, Transformation) is invoked.
      void startNow()
      Convenience method to start the animation at the current time in milliseconds.
      boolean willChangeBounds()
      Indicates whether or not this animation will affect the bounds of the animated view.
      boolean willChangeTransformationMatrix()
      Indicates whether or not this animation will affect the transformation matrix.
    • Field Detail

      • INFINITE

        public static final int INFINITE
        Repeat the animation indefinitely.
        See Also:
        Constant Field Values
      • RESTART

        public static final int RESTART
        When the animation reaches the end and the repeat count is INFINTE_REPEAT or a positive value, the animation restarts from the beginning.
        See Also:
        Constant Field Values
      • REVERSE

        public static final int REVERSE
        When the animation reaches the end and the repeat count is INFINTE_REPEAT or a positive value, the animation plays backward (and then forward again).
        See Also:
        Constant Field Values
      • START_ON_FIRST_FRAME

        public static final int START_ON_FIRST_FRAME
        Can be used as the start time to indicate the start time should be the current time when getTransformation(long, Transformation) is invoked for the first animation frame. This can is useful for short animations.
        See Also:
        Constant Field Values
      • ABSOLUTE

        public static final int ABSOLUTE
        The specified dimension is an absolute number of pixels.
        See Also:
        Constant Field Values
      • RELATIVE_TO_SELF

        public static final int RELATIVE_TO_SELF
        The specified dimension holds a float and should be multiplied by the height or width of the object being animated.
        See Also:
        Constant Field Values
      • RELATIVE_TO_PARENT

        public static final int RELATIVE_TO_PARENT
        The specified dimension holds a float and should be multiplied by the height or width of the parent of the object being animated.
        See Also:
        Constant Field Values
      • ZORDER_NORMAL

        public static final int ZORDER_NORMAL
        Requests that the content being animated be kept in its current Z order.
        See Also:
        Constant Field Values
      • ZORDER_TOP

        public static final int ZORDER_TOP
        Requests that the content being animated be forced on top of all other content for the duration of the animation.
        See Also:
        Constant Field Values
      • ZORDER_BOTTOM

        public static final int ZORDER_BOTTOM
        Requests that the content being animated be forced under all other content for the duration of the animation.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Animation

        public Animation()
        Creates a new animation with a duration of 0ms, the default interpolator, with fillBefore set to true and fillAfter set to false
      • Animation

        public Animation(Context context,
                 AttributeSet attrs)
        Creates a new animation whose parameters come from the specified context and attributes set.
        Parameters:
        context - the application environment
        attrs - the set of attributes holding the animation parameters
    • Method Detail

      • clone

        protected Animation clone()
                           throws CloneNotSupportedException
        Description copied from class: Object
        Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.
        Overrides:
        clone in class Object
        Returns:
        a copy of this object.
        Throws:
        CloneNotSupportedException - if this object's class does not implement the Cloneable interface.
      • cancel

        public void cancel()
        Cancel the animation. Cancelling an animation invokes the animation listener, if set, to notify the end of the animation. If you cancel an animation manually, you must call reset() before starting the animation again.
        See Also:
        reset(), start(), startNow()
      • detach

        public void detach()
      • isInitialized

        public boolean isInitialized()
        Whether or not the animation has been initialized.
        Returns:
        Has this animation been initialized.
        See Also:
        initialize(int, int, int, int)
      • initialize

        public void initialize(int width,
                      int height,
                      int parentWidth,
                      int parentHeight)
        Initialize this animation with the dimensions of the object being animated as well as the objects parents. (This is to support animation sizes being specified relative to these dimensions.)

        Objects that interpret Animations should call this method when the sizes of the object being animated and its parent are known, and before calling getTransformation(long, android.view.animation.Transformation).

        Parameters:
        width - Width of the object being animated
        height - Height of the object being animated
        parentWidth - Width of the animated object's parent
        parentHeight - Height of the animated object's parent
      • setListenerHandler

        public void setListenerHandler(Handler handler)
        Sets the handler used to invoke listeners.
      • setInterpolator

        public void setInterpolator(Context context,
                           int resID)
        Sets the acceleration curve for this animation. The interpolator is loaded as a resource from the specified context.
        Parameters:
        context - The application environment
        resID - The resource identifier of the interpolator to load
      • setInterpolator

        public void setInterpolator(Interpolator i)
        Sets the acceleration curve for this animation. Defaults to a linear interpolation.
        Parameters:
        i - The interpolator which defines the acceleration curve
      • setStartOffset

        public void setStartOffset(long startOffset)
        When this animation should start relative to the start time. This is most useful when composing complex animations using an AnimationSet where some of the animations components start at different times.
        Parameters:
        startOffset - When this Animation should start, in milliseconds from the start time of the root AnimationSet.
      • setDuration

        public void setDuration(long durationMillis)
        How long this animation should last. The duration cannot be negative.
        Parameters:
        durationMillis - Duration in milliseconds
        Throws:
        IllegalArgumentException - if the duration is < 0
      • restrictDuration

        public void restrictDuration(long durationMillis)
        Ensure that the duration that this animation will run is not longer than durationMillis. In addition to adjusting the duration itself, this ensures that the repeat count also will not make it run longer than the given time.
        Parameters:
        durationMillis - The maximum duration the animation is allowed to run.
      • scaleCurrentDuration

        public void scaleCurrentDuration(float scale)
        How much to scale the duration by.
        Parameters:
        scale - The amount to scale the duration.
      • startNow

        public void startNow()
        Convenience method to start the animation at the current time in milliseconds.
      • setRepeatMode

        public void setRepeatMode(int repeatMode)
        Defines what this animation should do when it reaches the end. This setting is applied only when the repeat count is either greater than 0 or INFINITE. Defaults to RESTART.
        Parameters:
        repeatMode - RESTART or REVERSE
      • setRepeatCount

        public void setRepeatCount(int repeatCount)
        Sets how many times the animation should be repeated. If the repeat count is 0, the animation is never repeated. If the repeat count is greater than 0 or INFINITE, the repeat mode will be taken into account. The repeat count is 0 by default.
        Parameters:
        repeatCount - the number of times the animation should be repeated
      • isFillEnabled

        public boolean isFillEnabled()
        If fillEnabled is true, this animation will apply the value of fillBefore.
        Returns:
        true if the animation will take fillBefore into account
      • setFillEnabled

        public void setFillEnabled(boolean fillEnabled)
        If fillEnabled is true, the animation will apply the value of fillBefore. Otherwise, fillBefore is ignored and the animation transformation is always applied until the animation ends.
        Parameters:
        fillEnabled - true if the animation should take the value of fillBefore into account
        See Also:
        setFillBefore(boolean), setFillAfter(boolean)
      • setFillBefore

        public void setFillBefore(boolean fillBefore)
        If fillBefore is true, this animation will apply its transformation before the start time of the animation. Defaults to true if setFillEnabled(boolean) is not set to true. Note that this applies when using an AnimationSet to chain animations. The transformation is not applied before the AnimationSet itself starts.
        Parameters:
        fillBefore - true if the animation should apply its transformation before it starts
        See Also:
        setFillEnabled(boolean)
      • setFillAfter

        public void setFillAfter(boolean fillAfter)
        If fillAfter is true, the transformation that this animation performed will persist when it is finished. Defaults to false if not set. Note that this applies to individual animations and when using an AnimationSet to chain animations.
        Parameters:
        fillAfter - true if the animation should apply its transformation after it ends
        See Also:
        setFillEnabled(boolean)
      • setZAdjustment

        public void setZAdjustment(int zAdjustment)
        Set the Z ordering mode to use while running the animation.
        Parameters:
        zAdjustment - The desired mode, one of ZORDER_NORMAL, ZORDER_TOP, or ZORDER_BOTTOM.
      • setBackgroundColor

        public void setBackgroundColor(int bg)
        Set background behind animation.
        Parameters:
        bg - The background color. If 0, no background. Currently must be black, with any desired alpha level.
      • setDetachWallpaper

        public void setDetachWallpaper(boolean detachWallpaper)
        If detachWallpaper is true, and this is a window animation of a window that has a wallpaper background, then the window will be detached from the wallpaper while it runs. That is, the animation will only be applied to the window, and the wallpaper behind it will remain static.
        Parameters:
        detachWallpaper - true if the wallpaper should be detached from the animation
      • getInterpolator

        public Interpolator getInterpolator()
        Gets the acceleration curve type for this animation.
        Returns:
        the Interpolator associated to this animation
      • getStartTime

        public long getStartTime()
        When this animation should start. If the animation has not startet yet, this method might return START_ON_FIRST_FRAME.
        Returns:
        the time in milliseconds when the animation should start or START_ON_FIRST_FRAME
      • getDuration

        public long getDuration()
        How long this animation should last
        Returns:
        the duration in milliseconds of the animation
      • getStartOffset

        public long getStartOffset()
        When this animation should start, relative to StartTime
        Returns:
        the start offset in milliseconds
      • getRepeatMode

        public int getRepeatMode()
        Defines what this animation should do when it reaches the end.
        Returns:
        either one of REVERSE or RESTART
      • getRepeatCount

        public int getRepeatCount()
        Defines how many times the animation should repeat. The default value is 0.
        Returns:
        the number of times the animation should repeat, or INFINITE
      • getFillBefore

        public boolean getFillBefore()
        If fillBefore is true, this animation will apply its transformation before the start time of the animation. If fillBefore is false and fillEnabled is true, the transformation will not be applied until the start time of the animation.
        Returns:
        true if the animation applies its transformation before it starts
      • getFillAfter

        public boolean getFillAfter()
        If fillAfter is true, this animation will apply its transformation after the end time of the animation.
        Returns:
        true if the animation applies its transformation after it ends
      • getBackgroundColor

        public int getBackgroundColor()
        Returns the background color behind the animation.
      • willChangeTransformationMatrix

        public boolean willChangeTransformationMatrix()

        Indicates whether or not this animation will affect the transformation matrix. For instance, a fade animation will not affect the matrix whereas a scale animation will.

        Returns:
        true if this animation will change the transformation matrix
      • willChangeBounds

        public boolean willChangeBounds()

        Indicates whether or not this animation will affect the bounds of the animated view. For instance, a fade animation will not affect the bounds whereas a 200% scale animation will.

        Returns:
        true if this animation will change the view's bounds
      • setAnimationListener

        public void setAnimationListener(Animation.AnimationListener listener)

        Binds an animation listener to this animation. The animation listener is notified of animation events such as the end of the animation or the repetition of the animation.

        Parameters:
        listener - the animation listener to be notified
      • ensureInterpolator

        protected void ensureInterpolator()
        Gurantees that this animation has an interpolator. Will use a AccelerateDecelerateInterpolator is nothing else was specified.
      • computeDurationHint

        public long computeDurationHint()
        Compute a hint at how long the entire animation may last, in milliseconds. Animations can be written to cause themselves to run for a different duration than what is computed here, but generally this should be accurate.
      • getTransformation

        public boolean getTransformation(long currentTime,
                                Transformation outTransformation)
        Gets the transformation to apply at a specified point in time. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.
        Parameters:
        currentTime - Where we are in the animation. This is wall clock time.
        outTransformation - A transformation object that is provided by the caller and will be filled in by the animation.
        Returns:
        True if the animation is still running
      • getTransformation

        public boolean getTransformation(long currentTime,
                                Transformation outTransformation,
                                float scale)
        Gets the transformation to apply at a specified point in time. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.
        Parameters:
        currentTime - Where we are in the animation. This is wall clock time.
        outTransformation - A transformation object that is provided by the caller and will be filled in by the animation.
        scale - Scaling factor to apply to any inputs to the transform operation, such pivot points being rotated or scaled around.
        Returns:
        True if the animation is still running
      • hasStarted

        public boolean hasStarted()

        Indicates whether this animation has started or not.

        Returns:
        true if the animation has started, false otherwise
      • hasEnded

        public boolean hasEnded()

        Indicates whether this animation has ended or not.

        Returns:
        true if the animation has ended, false otherwise
      • applyTransformation

        protected void applyTransformation(float interpolatedTime,
                               Transformation t)
        Helper for getTransformation. Subclasses should implement this to apply their transforms given an interpolation value. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.
        Parameters:
        interpolatedTime - The value of the normalized time (0.0 to 1.0) after it has been run through the interpolation function.
        t - The Transformation object to fill in with the current transforms.
      • resolveSize

        protected float resolveSize(int type,
                        float value,
                        int size,
                        int parentSize)
        Convert the information in the description of a size to an actual dimension
        Parameters:
        type - One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
        value - The dimension associated with the type parameter
        size - The size of the object being animated
        parentSize - The size of the parent of the object being animated
        Returns:
        The dimension to use for the animation
      • getInvalidateRegion

        public void getInvalidateRegion(int left,
                               int top,
                               int right,
                               int bottom,
                               RectF invalidate,
                               Transformation transformation)
        Parameters:
        left -
        top -
        right -
        bottom -
        invalidate -
        transformation -
      • initializeInvalidateRegion

        public void initializeInvalidateRegion(int left,
                                      int top,
                                      int right,
                                      int bottom)
        Parameters:
        left -
        top -
        right -
        bottom -
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
        Throws:
        Throwable
      • hasAlpha

        public boolean hasAlpha()
        Return true if this animation changes the view's alpha property.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 134 / 158848813. Delta: 0.05110 с