Android Animation (5) Viewswitcher

Source: Internet
Author: User

The role of Viewswitcher is simply to show animations when converting between two views

Its two subclasses should be familiar,

Imageswitcher: Increase animation effect when converting pictures;

Textswitcher: Increase animation effect when converting text;

Layout:

<?XML version= "1.0" encoding= "Utf-8"?> <Viewswitcher xmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/view_switcher"Android:layout_width= "Match_parent"android:inanimation= "@android: Anim/slide_in_left"android:outanimation= "@android: Anim/slide_out_right"Android:layout_height= "Match_parent" >        <!--First View -    <RelativelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent">        <ButtonAndroid:id= "@+id/ne"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_centervertical= "true"Android:text= "Next"/>    </Relativelayout>        <!--a second view -    <RelativelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent">        <ButtonAndroid:id= "@+id/up"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_centervertical= "true"Android:text= "Previous"/>        <ImageViewAndroid:id= "@+id/image"Android:layout_torightof= "@id/up"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_centervertical= "true"android:src= "@drawable/ic_launcher"/>    </Relativelayout></Viewswitcher>

Switching of the interface

 Public classViewswitcheractextendsactivity{PrivateViewswitcher switcher; PrivateButton Upper,next; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.view_switcher); Switcher=(Viewswitcher) Findviewbyid (R.id.view_switcher); Upper=(Button) Findviewbyid (r.id.up); Next=(Button) Findviewbyid (r.id.ne);  // switch to the first view switcher.setdisplayedchild (0); Upper.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {switcher.showprevious ();            }        }); Next.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {switcher.shownext ();            }        }); }}

Layout:

Android Animation (5) Viewswitcher

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.