Sliding pages (with animations) and tagging with tabactivity

Source: Internet
Author: User

First view results

In fact, it was discovered that tabactivity is not difficult to use. You only need to expand some of its methods to achieve the desired effect. If you don't want to talk about it, paste the animation implementation part, and view the source code for others.

@ Overridepublic void setcurrenttab (INT index) {int mcurrenttabid = getcurrenttab (); If (null! = Getcurrentview () {// This value is null when tab is set for the first time. If (isopenanimation) {If (mcurrenttabid = (mtabcount-1) & Index = 0) {getcurrentview (). startanimation (slideleftout);} else if (mcurrenttabid = 0 & Index = (mtabcount-1) {getcurrentview (). startanimation (sliderightout);} else if (index> mcurrenttabid) {getcurrentview (). startanimation (slideleftout);} else if (index <mcurrenttabid) {getcurrentview (). startanimation (sliderightout) ;}} super. setcurrenttab (INDEX); If (isopenanimation) {If (mcurrenttabid = (mtabcount-1) & Index = 0) {getcurrentview (). startanimation (slideleftin);} else if (mcurrenttabid = 0 & Index = (mtabcount-1) {getcurrentview (). startanimation (sliderightin);} else if (index> mcurrenttabid) {getcurrentview (). startanimation (slideleftin);} else if (index <mcurrenttabid) {getcurrentview (). startanimation (sliderightin );}}}

This program is android2.2.

However, it inherits the tabhost component class and extends its setcurrenttab (INT index) method. However, there is a bug that cannot be solved, so when you slide the screen continuously and quickly, when the view or activity background image loaded by the tabhost is transparent, a shadow occurs.

Hope you can solve the problem.

You can view the XML file to get the answer about the tag base. When using tabactivity, the top-level view of the layout file must be the tabhost control. You can see the source code of tabhost, it is actually a framelayout, which contains two controls: framelayout mtabcontent (displaying the view or activity we load) and tabwidget mtabwidget (displaying the tab is actually a linearlayout ), the default layout is system, so we can
In the XML file, you can change the order of the two items. Similarly, since we can get tabwidget, we can design its layout, the effect can be achieved.

Now I want to come. Will QQ, UC, and other beautiful button slide methods be implemented in this way? study ............

Complete code:Http://download.csdn.net/detail/cpcpc/3600134

 

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.