A. Sliding interface:
In addition to starting the animation on the first start, there may also be a sliding function introduction interface, now record the implementation of this interface, and then the previous animation after the effect attached.
:
Interface:
public class Slideactivity extends Activity{private viewpager mviewpager;private ImageView mpage0;private ImageView Mpage1;private ImageView mpage2;private ImageView mpage3;private ImageView mpage4;private ImageView mPage5; @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.whatsnew_viewpager); Mviewpager = (Viewpager) Findviewbyid (R.id.whatsnew_viewpager); Mviewpager.setonpagechangelistener (New Myonpagechangelistener ()); MPAGE0 = (ImageView) Findviewbyid (R.ID.PAGE0); MPage1 = (ImageView) Findviewbyid (r.id.page1); MPage2 = (ImageView) Findviewbyid (r.id.page2); MPage3 = (ImageView) Findviewbyid (R.ID.PAGE3); MPage4 = (ImageView) Findviewbyid (r.id.page4); MPage5 = (ImageView) Findviewbyid (R.ID.PAGE5); The view that will be paginated is loaded into the array layoutinflater mLi = Layoutinflater.from (this); View view1 = mli.inflate (r.layout.wHATS1, NULL); View view2 = mli.inflate (r.layout.whats2, NULL); View view3 = mli.inflate (R.LAYOUT.WHATS3, NULL); View view4 = mli.inflate (R.LAYOUT.WHATS4, NULL); View view5 = mli.inflate (R.LAYOUT.WHATS5, NULL); View view6 = mli.inflate (r.layout.whats6, NULL); View data for each page final arraylist<view> views = new arraylist<view> (); Views.add (View1); Views.add (VIEW2); Views.add (VIEW3); Views.add (VIEW4); Views.add (VIEW5); Views.add (VIEW6); Data adapter populated with Viewpager pageradapter mpageradapter = new Pageradapter () {@Overridepublic Boolean isviewfromobject (View arg0, Object arg1) {return arg0 = = arg1;} @Overridepublic int GetCount () {return views.size ();} @Overridepublic void Destroyitem (View container, int position, object object) {(Viewpager) container). Removeview ( Views.get (position));} @Overridepublic Object Instantiateitem (View container, int position) {(Viewpager) containER). AddView (Views.get (position)); return views.get (position);}}; Mviewpager.setadapter (Mpageradapter); } public class Myonpagechangelistener implements Onpagechangelistener {@Overridepublic void onpageselected (int ARG0) {switch (arg0) {case 0:mpage0.setimagedrawable (getresources (). getdrawable (R.drawable.page_now)); Mpage1.setimagedrawable (Getresources (). getdrawable (R.drawable.page)); Break;case 1:mpage1.setimagedrawable ( Getresources (). getdrawable (R.drawable.page_now)); Mpage0.setimagedrawable (Getresources (). GetDrawable ( R.drawable.page)); Mpage2.setimagedrawable (Getresources () getdrawable (r.drawable.page)); Break;case 2: Mpage2.setimagedrawable (Getresources (). getdrawable (R.drawable.page_now)); Mpage1.setimagedrawable (GetResources ( ). Getdrawable (R.drawable.page)); Mpage3.setimagedrawable (Getresources (). getdrawable (R.drawable.page)); break; Case 3:mpage3.setimagedrawable (Getresources (). getdrawable (R.drawable.page_now)); Mpage4.setimagedrawable ( Getresources (). getdrawable (R.drawable.page));Mpage2.setimagedrawable (Getresources (). getdrawable (R.drawable.page)); Break;case 4:mpage4.setimagedrawable ( Getresources (). getdrawable (R.drawable.page_now)); Mpage3.setimagedrawable (Getresources (). GetDrawable ( R.drawable.page)); Mpage5.setimagedrawable (Getresources () getdrawable (r.drawable.page)); Break;case 5: Mpage5.setimagedrawable (Getresources (). getdrawable (R.drawable.page_now)); Mpage4.setimagedrawable (GetResources ( ). Getdrawable (R.drawable.page)); break;} Animation.setfillafter (TRUE);//true: The picture stops at the end of the animation//animation.setduration (+);//mpageimg.startanimation ( animation);} @Overridepublic void onpagescrolled (int arg0, float arg1, int arg2) {} @Overridepublic void onpagescrollstatechanged (int a rg0) {}} public void Startbutton (View v) {Intent Intent = new Intent (); Intent.setclass (Slideactivity.this,testa Ctivity.class); startactivity (intent); This.finish (); } }
Layout:
<?xml version= "1.0" encoding= "Utf-8"? ><framelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" fill_parent "android:orientation=" vertical "&G T <android.support.v4.view.viewpager android:id= "@+id/whatsnew_viewpager" android:layout_width= "Wrap_conten T "android:layout_height=" wrap_content "android:layout_gravity=" center "> <and Roid.support.v4.view.PagerTitleStrip android:id= "@+id/pagertitle" android:layout_width= "wrap_content "Android:layout_height=" 0DP "android:layout_gravity=" Bottom "android:background=" #0000 " Android:textcolor= "#ffff"/> </android.support.v4.view.ViewPager> <linearlayout Android:layout_width= "Match_parent" android:layout_height= "match_parent" android:orientation= "Horizontal" > &Lt LinearLayout android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android oid:layout_gravity= "Bottom" android:layout_marginbottom= "30DP" android:gravity= "Center_horizontal" > <imageview android:id= "@+id/page0" android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:scaletype= "Matrix" android:src= "@drawable/page_no W "/> <imageview android:id=" @+id/page1 "android:layout_width=" Wrap_content "and roid:layout_height= "Wrap_content" android:layout_marginleft= "10DP" android:scaletype= "Matrix" android:src= "@drawable/page"/> <imageview android:id= "@+id/page2" android:layout _width= "Wrap_content" android:layout_height= "wrap_content" android:layout_marginleft= "10DP" Android:scaletYpe= "Matrix" android:src= "@drawable/page"/> <imageview android:id= "@+id/page3" Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_marginleft= "10DP" Android:scaletype= "Matrix" android:src= "@drawable/page"/> <imageview Android:id= "@+id/page4" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_marginleft= "10DP" android:scaletype= "Matrix" android:src= "@drawable/page"/&G T <imageview android:id= "@+id/page5" android:layout_width= "Wrap_content" android:layout_height= " Wrap_content "android:layout_marginleft=" 10DP "android:scaletype=" Matrix "android:src = "@drawable/page"/> </LinearLayout> </LinearLayout> </frameLayout>
Layout of each view:
<?xml version= "1.0" encoding= "UTF-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:orientation=" vertical " android:background=" @drawable/w1 " android:layout_width=" Fill_parent " android:layout_height=" fill_parent " > <textview android:layout_width=" Fill_ Parent " android:layout_height=" wrap_content " android:gravity=" center " android:text=" \ n Travel diary \ N is a must-have app for your travels " android:layout_alignparenttop=" true " android:layout_margintop=" 35DP " android: Textsize= "22SP" android:textcolor= "#fff" /></relativelayout>
if you want to achieve the first start of the display, with Sharedpreferences store the information on the line, each start judgment, OK.
Android first start slide interface