public class

ViewAnimator

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.widget.ViewAnimator
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Base class for a FrameLayout container that will perform animations when switching between its views.

Summary

XML Attributes
Attribute Name Related Method Description
android:inAnimation  
android:outAnimation  
[Expand]
Inherited XML Attributes
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
Public Constructors
ViewAnimator(Context context)
ViewAnimator(Context context, AttributeSet attrs)
Public Methods
void addView(View child, int index, ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters.
int getBaseline()

Return the offset of the widget's text baseline from the widget's top boundary.

View getCurrentView()
Returns the View corresponding to the currently displayed child.
int getDisplayedChild()
Returns the index of the currently displayed child view.
Animation getInAnimation()
Returns the current animation used to animate a View that enters the screen.
Animation getOutAnimation()
Returns the current animation used to animate a View that exits the screen.
void removeAllViews()
Call this method to remove all child views from the ViewGroup.
void removeView(View view)
void removeViewAt(int index)
Removes the view at the specified position in the group.
void removeViewInLayout(View view)
Removes a view during layout.
void removeViews(int start, int count)
Removes the specified range of views from the group.
void removeViewsInLayout(int start, int count)
Removes a range of views during layout.
void setAnimateFirstView(boolean animate)
Indicates whether the current View should be animated the first time the ViewAnimation is displayed.
void setDisplayedChild(int whichChild)
Sets which child view will be displayed.
void setInAnimation(Animation inAnimation)
Specifies the animation used to animate a View that enters the screen.
void setInAnimation(Context context, int resourceID)
Specifies the animation used to animate a View that enters the screen.
void setOutAnimation(Animation outAnimation)
Specifies the animation used to animate a View that exit the screen.
void setOutAnimation(Context context, int resourceID)
Specifies the animation used to animate a View that exit the screen.
void showNext()
Manually shows the next child.
void showPrevious()
Manually shows the previous child.
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent

XML Attributes

android:inAnimation

Related Methods

android:outAnimation

Related Methods

Public Constructors

public ViewAnimator (Context context)

public ViewAnimator (Context context, AttributeSet attrs)

Public Methods

public void addView (View child, int index, ViewGroup.LayoutParams params)

Adds a child view with the specified layout parameters.

Parameters
child the child view to add
index the position at which to add the child
params the layout parameters to set on the child

public int getBaseline ()

Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.

Returns
  • the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported

public View getCurrentView ()

Returns the View corresponding to the currently displayed child.

Returns
  • The View currently displayed.

public int getDisplayedChild ()

Returns the index of the currently displayed child view.

public Animation getInAnimation ()

Returns the current animation used to animate a View that enters the screen.

Returns
  • An Animation or null if none is set.

public Animation getOutAnimation ()

Returns the current animation used to animate a View that exits the screen.

Returns
  • An Animation or null if none is set.

public void removeAllViews ()

Call this method to remove all child views from the ViewGroup.

public void removeView (View view)

public void removeViewAt (int index)

Removes the view at the specified position in the group.

Parameters
index the position in the group of the view to remove

public void removeViewInLayout (View view)

Removes a view during layout. This is useful if in your onLayout() method, you need to remove more views.

Parameters
view the view to remove from the group

public void removeViews (int start, int count)

Removes the specified range of views from the group.

Parameters
start the first position in the group of the range of views to remove
count the number of views to remove

public void removeViewsInLayout (int start, int count)

Removes a range of views during layout. This is useful if in your onLayout() method, you need to remove more views.

Parameters
start the index of the first view to remove from the group
count the number of views to remove from the group

public void setAnimateFirstView (boolean animate)

Indicates whether the current View should be animated the first time the ViewAnimation is displayed.

Parameters
animate True to animate the current View the first time it is displayed, false otherwise.

public void setDisplayedChild (int whichChild)

Sets which child view will be displayed.

Parameters
whichChild the index of the child view to display

public void setInAnimation (Animation inAnimation)

Specifies the animation used to animate a View that enters the screen.

Parameters
inAnimation The animation started when a View enters the screen.

public void setInAnimation (Context context, int resourceID)

Specifies the animation used to animate a View that enters the screen.

Parameters
context The application's environment.
resourceID The resource id of the animation.

public void setOutAnimation (Animation outAnimation)

Specifies the animation used to animate a View that exit the screen.

Parameters
outAnimation The animation started when a View exit the screen.

public void setOutAnimation (Context context, int resourceID)

Specifies the animation used to animate a View that exit the screen.

Parameters
context The application's environment.
resourceID The resource id of the animation.

public void showNext ()

Manually shows the next child.

public void showPrevious ()

Manually shows the previous child.