The Viewanimator can realize the View Toggle of the drawing effect , and its derived subclasses are some of the components with animation effect switching function.
XML attributes supported by Viewanimator:
Attribute Name |
Description |
Android:animatefirstview |
Set whether animations are used when displaying the first view component |
Android:inanimation |
To set the animation used when displaying components |
Android:outanimation |
Animate when you set a hidden component |
1. Viewswitcher View switch component.
Ways to add Views:
Create Viewfrom viewfactory , and then through viewswitcher 's setfactory ( Viewswitcher.viewfactory) added.
Switch:
Showprevious () and shownext ()
2.ImageSwitcher Image Switcher
The View component returned by the Viewfactory Makeview () method must be ImageView .
Because the showprevious () and shownext () methods are overridden, you can call setimagedrawable (drawable drawable),setimageresource (int resid) , and Setimageuri (Uri uri) methods to replace the picture.
3. Textswitcher Text Switcher
The View component returned by the Viewfactory Makeview () method must be TextView .
When you switch text, you only need to call the SetText () method.
4.ViewFlipper
Inherited from viewanimator, like the adapterviewflipper, there are many common XML attributes, but do not need to pass Adapter Add a list item, you can add multiple viewby AddView (view v) .
Android Learning Note (25): View Toggle Viewanimator and its subclasses that drive the drawing effect