Android (7) 360 Interface implementation

Source: Internet
Author: User

I. 360 implementation of the interface:

Read someone else's source code and then perfect a bit, this interface to achieve up or not trouble (to the source of the left mailbox, I send you).

:






Main interface:

public class Mainactivity extends Activity {private ImageView ivone;private ImageView ivtwo;private ImageView button1;pri Vate ImageView button2;private ImageView button3;private ImageView button4;/* * accelerateinterpolator rate change is slow at the beginning of the animation, And then start accelerating bounceinterpolator * When the animation is over, bounce decelerateinterpolator at the beginning of the animation, then slow ... *///Animation Acceleration Private interpolator accelerator = new Accelerateinterpolator ();//animation deceleration private Interpolator Decelerator = new Dec     Elerateinterpolator ();p rivate viewpager vpmain;private list<view> views;     Private View Viewone; Private View viewtwo; @Overrideprotected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method Stubsuper.oncreate (savedinstancestate); Setview (); Initview (); Setlistener ();} public void Setview () {requestwindowfeature (window.feature_no_title); Setcontentview (R.layout.activity_main);} public void Initview () {//pages button Ivone = (ImageView) Findviewbyid (r.id.viewpager_one); ivtwo = (ImageView) Findviewbyid ( R.id.viewpager_two); button1 = (ImageView) Findviewbyid (r.id.button1), button2 = (ImageView) Findviewbyid (r.id.button2); Button3 = (ImageView) Findviewbyid ( R.id.button3) Button4 = (ImageView) Findviewbyid (R.ID.BUTTON4);//Viewpagervpmain = (Viewpager) Findviewbyid (        R.id.viewpager_main); views = new arraylist<view> ();        Viewone = View.inflate (this, r.layout.activity_main_one, null); Views.add (Viewone);        Viewtwo = View.inflate (this, r.layout.activity_mian_two, null); Views.add (Viewtwo); Myadapter adapter = new Myadapter (); MyListener listener = new MyListener () Vpmain.setadapter (adapter);//monitor slide Vpmain.setonpagechangelistener (listener); LinearLayout activity_main_one_layout = (linearlayout) Viewone.findviewbyid (r.id.activity_main_one_layout); for (int i = 0; I < Activity_main_one_layout.getchildcount (); i++) {for (int j = 0; J < (LinearLayout) Activity_main_one_layout.getchildat (i)). Getchildcount (); j + +) {Final int II = i ; final int JJ = J; ((LinearLayout) Activity_main_one_layout.getchildat (i)). Getchildat (J). Setonclicklistener (New View.onclicklistener () {@Overridepublic void OnClick (View arg0) {Toast.maketext ( Mainactivity.this, "+ii+" line, section "+jj+", Toast.length_short). Show ();}});}} public void Setlistener () {Ivone.setonclicklistener (New Imageviewonclicklistener ()); Ivtwo.setonclicklistener (new Imageviewonclicklistener ()); Button1.setonclicklistener (new Imageviewonclicklistener ()); Button2.setonclicklistener (New Imageviewonclicklistener ()); Button3.setonclicklistener (new Imageviewonclicklistener ()); Button4.setonclicklistener (new Imageviewonclicklistener ());} Click ImageView, two page switching method private void Flipit (view one, view two) {Final view visible;final view invisible;//judgment two view that is hidden , and then toggle if (one.getvisibility () = = View.gone) {Visible = Two;invisible = one;} else {invisible = two;visible = one;} Animate, rotate with x-axis Objectanimator Vistoinvis = objectanimator.offloat (Visible, "RotationX", 0f, 90f);// Set time Vistoinvis.setduration (500);//Set Animation change rate vistoinvis.setinterpolator (accelerator); final Objectanimator InvistoVis = Objectanimator.offloat (Invisible, "RotationX", -90f, 0f); invistovis.setduration (500); Invistovis.setinterpolator (Decelerator); Vistoinvis.addlistener (new Animatorlisteneradapter () {@Overridepublic void Onanimationend (Animator anim) {visible.setvisibility (view.gone); Invistovis.start (); Invisible.setvisibility ( view.visible);});    Vistoinvis.start ();} Adapter class Myadapter extends Pageradapter {@Overridepublic int getcount () {return views.size ();} @Overridepublic Boolean isviewfromobject (view view, Object obj) {return view = = obj;} @Overridepublic void Destroyitem (ViewGroup container, int position, object object) {Container.removeview (Views.get ( position));} @Overridepublic Object Instantiateitem (viewgroup container, int position) {Container.addview (Views.get (position));    return Views.get (position);}} Slide Monitor class MyListener implements Onpagechangelistener {//the finger is changed when the screen is manipulated @overridepublic void onpagescrollstatechanged (int arg0) {}//is constantly being called during screen scrolling @overridepublic void onpagescrolled (int arg0, float arg1, int arg2) {}//Finger sliding page, the distance is long enough, the finger will be lifted up immediately execute this method, arg0 is the number of pages @overridepublic void onpageselected (int arg0) {    Flipit (Ivone, Ivtwo);}} ImageView Listener Class Imageviewonclicklistener implements View.onclicklistener {@Overridepublic void OnClick (View arg0) { Switch (Arg0.getid ()) {case R.id.button1:toast.maketext (mainactivity.this, "I want to download", Toast.length_short). Show (); break Case R.id.button2:toast.maketext (mainactivity.this, "I want to delete", Toast.length_short). Show (); Break;case R.id.button3: Toast.maketext (Mainactivity.this, "I want to set", Toast.length_short). Show (); Break;case R.id.button4:toast.maketext ( Mainactivity.this, "I want to add", Toast.length_short). Show (); Break;case r.id.viewpager_one:flipit (Ivone, IVTWO);// Setcurrentitem the number of pages selected, Getcurrentitem returns the current number of pages Vpmain.setcurrentitem ((Vpmain.getcurrentitem () + 1)% views.size ()); Case R.id.viewpager_two:flipit (Ivone, ivtwo); Vpmain.setcurrentitem ((Vpmain.getcurrentitem () + 1)% views.size ()); Break;}}}}

Main interface layout:

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:background=" @drawable/w        6 "> <linearlayout android:layout_width=" wrap_content "android:layout_height=" Wrap_content " Android:gravity= "center_vertical" android:orientation= "vertical" android:layout_margin= "10DP" Android :p addingleft= "5DP" > <linearlayout android:id= "@+id/title" android:layout_width= "Wrap_c Ontent "android:layout_height=" 60DP "android:layout_marginbottom=" 10DP "Android:layout_ma rginleft= "15DP" android:layout_margintop= "8DP" android:orientation= "vertical" > <te                Xtview android:layout_width= "wrap_content" android:layout_height= "Wrap_content"         Android:padding= "5DP"       android:text= "haha" android:textcolor= "#aaffffff" android:textscalex= "1.2" Android:textsize= "20SP" > </TextView> <textview android:layout_width                = "Wrap_content" android:layout_height= "wrap_content" android:text= "haha haha haha" Android:textcolor= "#88ffffff" android:textsize= "15SP" > </TextView> </linearl ayout> <android.support.v4.view.viewpager android:id= "@+id/viewpager_main" Android:layo Ut_width= "Wrap_content" android:layout_height= "wrap_content"/> </LinearLayout> < Relativelayout android:layout_width= "50DP" android:layout_height= "Match_parent" ANDROID:LAYOUT_ALIGNP Arentright= "true" android:paddingbottom= "30DP" android:paddingright= "5DP" android:paddingtop= "60DP" &        Gt  <include          Android:id= "@+id/main_sb" android:layout_width= "wrap_content" android:layout_height= "Wrap_ Content "layout=" @layout/activity_main_left "/> <imageview android:id=" @+id/viewpager_o Ne "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "Android:layo Ut_alignparentbottom= "true" android:background= "@drawable/rootblock_main_page_one"/> < ImageView android:id= "@+id/viewpager_two" android:layout_width= "Wrap_content" Android:lay out_height= "Wrap_content" android:layout_alignparentbottom= "true" android:background= "@drawable/root Block_main_page_two "android:visibility=" Gone "/> </RelativeLayout></RelativeLayout>

Left layout:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Wrap_content "android:layout_height=" wrap_content "android:orientation=" vertical " > <imageview android:id= "@+id/button1" android:layout_width= "36DP" android:layout_height= "36        DP "android:src=" @drawable/rootblock_icon_download_bg "/> <imageview android:id=" @+id/button2 " Android:layout_width= "36DP" android:layout_height= "36DP" android:layout_margintop= "20DP" android:s rc= "@drawable/rootblock_icon_clear_bg"/> <imageview android:id= "@+id/button3" android:layout_width = "36DP" android:layout_height= "36DP" android:layout_margintop= "20DP" android:src= "@drawable/rootblock _icon_set_bg "/> <imageview android:id=" @+id/button4 "android:layout_width=" 36DP "Android:la yout_height= "36DP" android:layout_margintop= "20DP" android:src= "@drawable/rootblock_icon_add_bg"/></linearlayout> 

First Page view:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/    Android "Android:layout_width=" Wrap_content "android:layout_height=" wrap_content "android:paddingbottom=" 30DP " android:orientation= "vertical" android:id= "@+id/activity_main_one_layout" > <linearlayout android:layo Ut_width= "Wrap_content" android:layout_height= "wrap_content" android:orientation= "Horizontal" > &L T LinearLayout android:layout_width= "110DP" android:layout_height= "80DP" Android:background = "#000000" > </LinearLayout> <linearlayout android:layout_width= "110DP" and roid:layout_height= "80DP" android:layout_marginleft= "5DP" android:background= "#000000" > & lt;/linearlayout> </LinearLayout> <linearlayout android:layout_width= "Wrap_content" Androi   d:layout_height= "Wrap_content"     android:layout_margintop= "5DP" android:orientation= "horizontal" > <linearlayout Androi D:layout_width= "110DP" android:layout_height= "80DP" android:background= "#3399ff" > </li            nearlayout> <linearlayout android:layout_width= "110DP" android:layout_height= "80DP" android:layout_marginleft= "5DP" android:background= "#3399ff" > </LinearLayout> </ linearlayout> <linearlayout android:layout_width= "wrap_content" android:layout_height= "wrap_content "Android:layout_margintop=" 5DP "android:orientation=" Horizontal "> <linearlayout an Droid:layout_width= "110DP" android:layout_height= "80DP" android:background= "#3399ff" > &lt             ;/linearlayout> <linearlayout android:layout_width= "110DP" android:layout_height= "80DP" Android:layout_marginleft= "5DP" android:background= "#3399ff" > </LinearLayout> </LinearLayout> <linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:lay out_margintop= "5DP" android:orientation= "horizontal" > <linearlayout android:layout_width= "         110DP "android:layout_height=" 80DP "android:background=" #953399ff "> </LinearLayout> <linearlayout android:layout_width= "110DP" android:layout_height= "80DP" Androi d:layout_marginleft= "5DP" android:background= "#953399ff" > </LinearLayout> </linearlayout ></LinearLayout>

Second Page view:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/    Android "Android:layout_width=" Wrap_content "android:layout_height=" wrap_content "android:orientation=" vertical " android:paddingbottom= "30DP" > <linearlayout android:layout_width= "wrap_content" Android:layout_ height= "wrap_content" android:orientation= "horizontal" > <linearlayout android:layout_width         = "110DP" android:layout_height= "80DP" android:background= "#FF7F24" > </LinearLayout> <linearlayout android:layout_width= "110DP" android:layout_height= "80DP" Androi d:layout_marginleft= "5DP" android:background= "#FF7F24" > </LinearLayout> &LT;/LINEARLAYOUT&G    T <linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:lay Out_margintop= "5DP" android:orientation= "Horizontal" > <linearlayout android:layout_width= "110DP" Android:lay            out_height= "80DP" android:background= "#3399ff" > </LinearLayout> <linearlayout            Android:layout_width= "110DP" android:layout_height= "80DP" android:layout_marginleft= "5DP" android:background= "#3399ff" > </LinearLayout> </LinearLayout> <linearlayout A        Ndroid:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_margintop= "5DP" android:orientation= "Horizontal" > <linearlayout android:layout_width= "110DP" Android            : layout_height= "80DP" android:background= "#3399ff" > </LinearLayout> <linearlayout            Android:layout_width= "110DP" android:layout_height= "80DP" android:layout_marginleft= "5DP" Android:background= "#3399ff" > </LinearLayout> </LinearLayout> <linearlayout android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_margintop= "5DP" Android:orientatio n= "Horizontal" > <linearlayout android:layout_width= "110dp" android:layout_height= "80DP "android:background=" #953399ff "> </LinearLayout> <linearlayout android:l Ayout_width= "110DP" android:layout_height= "80DP" android:layout_marginleft= "5DP" Android: background= "#953399ff" > </LinearLayout> </LinearLayout></LinearLayout>

Drawable:

<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item android:state_focused=" true "android:drawable=" @drawable/rootblock_icon_add "></ Item><item android:state_pressed= "true" android:drawable= "@drawable/rootblock_icon_add_selected" ></ Item><item android:state_enabled= "true" android:drawable= "@drawable/rootblock_icon_add" ></item> </selector>

The other three XML is the same.




Android (7) 360 Interface implementation

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.