Introduction to the android tab (IV)

Source: Internet
Author: User

The usage of the options described in the previous sections basically uses tabactivity and viewpager to meet the development requirements. However, here is another tips. Sometimes, when using viewpager and fragment in front of the page, you may feel a little useless.

Http://blog.csdn.net/xia215266092/article/details/9613897

Http://blog.csdn.net/xia215266092/article/details/9613985

Http://blog.csdn.net/xia215266092/article/details/9616075

For example, in the following case, there is a tab in the Weibo interface. All tabs, I listened to, and authenticated users can be implemented if viewpager + fragment is used. However, today I will introduce the use of viewflipper to view the API documentation. viewflipper can contain many classes, but only one view can be displayed at a time, in this way, the switch between labels in the image is basically satisfied.

The layout structure can be as follows.

<Viewflipper>

<Listview/>

<Listview/>

<Listview/>

</Viewflipper>

The following is the method for switching the page. shownext and shorpervious are the previous and next Display respectively. setdisplayedchild is the specific display of a subview, And the passed parameter is the position of ziview.

Void Shownext () Manually shows the next child.
Void Showprevious () Manually shows the previous child.
Void Setdisplayedchild (int
Whichchild) Sets which child view will be displayed.

Another advantage of using viewflipper is that you can easily customize the animation during switching.

Void Setinanimation (animation inanimation) 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.

The first is the animation when the view comes in, and the second is the animation when the view goes out. If the animation is set well, the effect is also very good. If the above animation is set, you can set loop and automatically play all pages, similar to gallery. If you want to learn more, you still need to view the documentation.

Public class

Viewanimator

Extends framelayout

Java. Lang. Object
Bytes Android. View. View
  Bytes Android. View. viewgroup
    Bytes Android. widget. framelayout
      Bytes Android. widget. viewanimator
Known
Direct subclasses

Viewflipper, viewswitcher
Known
Indirect subclasses

Imageswitcher, textswitcher

Viewanimator and viewflipper, viewswticher, imageswitch, and textswitcher have similar functions, but they only apply to different objects.

Related Article

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.