Android Study Notes (25): switches ViewAnimator and its subclass for views with animation Effects
ViewAnimator allows you to switch between views with animation effects. Its Derived subclass is a component with animation effect switching function.
XML attributes supported by ViewAnimator:
Attribute Name |
Description |
Android: animateFirstView |
Sets whether to use an animation when displaying the first View component. |
Android: inAnimation |
Set the animation used for displaying Components |
Android: outAnimation |
Sets the animation used to hide a widget. |
1. Switch the ViewSwitcher view component.
How to add a view:
Create a View from ViewFactory and add it through setFactory (ViewSwitcher. ViewFactory) of ViewSwitcher.
Switch:
ShowPrevious () and showNext ()
2. ImageSwitcher image switcher
The View component returned by the makeView () method of ViewFactory must be ImageView.
Because the showPrevious () and showNext () methods are overwritten, you can change an image by calling the setImageDrawable (Drawable drawable), setImageResource (int resid), and setImageURI (Uri uri) methods.
3. TextSwitcher text Switch
The View component returned by the makeView () method of ViewFactory must be TextView.
When switching text, you only need to call the setText () method.
4. ViewFlipper
Inherited from ViewAnimator, like AdapterViewFlipper, there are also many common XML attributes. However, you do not need to add list items through Adapter. You can add multiple views through addView (View v.