Android Study Notes (25): switches ViewAnimator and its subclass for views with animation Effects

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.