Android activity Toggle Animation Effect Library Switchlayout, view Toggle Animation Library, comparable to iOS

Source: Internet
Author: User
Tags comparable


Thanks to the view interface switching animation experience of the app developed by many developers on iOS is very good, these are all iOS comes with, but Android's activity and other view switch animations do not provide native, So I wrote an android view switch animation effect library that can match iOS view toggle animation! switchlayout! Can be said to be the first on Android, but also the only one powerful view switch animation library engine!


Tan Dong

qq:852041173

Project Open Source! It is recommended to use JAR package form!

Without the author's permission, the project library source code can not be modified to release itself.

If you are using Swtichlayout in your project, it is recommended that you provide support in your app on the page stating Switchlayout library! Thank you so much! If you feel switchlayout strong, you are welcome to recommend to your friends.

If there is any suggestion, also can feedback to me, will upgrade Switchlayout library in time.


Switchlayout 1.0jar Package and Demo:http://pan.baidu.com/s/1dd6balv

Source code will be hosted on GitHub in the near future


Well, first look at the main interface supported by the view switch effect bar! (This is demo)





The effect engine is good enough to match iOS.

Within the list, the custom extension engine interface that each effect exposes can probably extend 8 effects. So there are probably 105 different effects to be expanded! Strong enough!


OK, here's the general usage:

1. Import the Switchlayout1.0.jar or download the Open Source Library.

2. Each activity implements the interface implements Swichlayoutinterface. This usage is recommended, and the interfaces are implemented in 2 ways: Setenterswichlayout (), and setexitswichlayout (); These two methods are animations that set into activity animation and leave activity, respectively.

Call Setenterswichlayout () in OnCreate (); Call Setexitswichlayout () in the close activity operation; If necessary, intercept the return button in onkeydown and call Setexitswichlayout ();


3. Specific effects call (for example): Switchlayout.getslidefrombottom (This, false,baseeffects.getmoresloweffect ());

Three parameters are (Activity/view, whether to close Activity, special effects (can be empty)), each special effect supports 8 kinds of expansion, you can also do not fill the effect.

4. Note that in the Project registration list, each activity is subject to a transparent theme. Android:theme= "@android: Style/theme.translucent", API is above 11.

Paste the following code in the Switchlayoutdemo:

Package Com.tandong.swichlayoutdemo;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.view.view;import Android.view.view.onclicklistener;import Android.view.Window; Import Android.widget.button;import Com.tandong.swichlayout.baseeffects;import com.tandong.swichlayout.switchlayout;/** * switchlayout * * QQ 852041173 * * For Android to provide the iOS platform's own interface view switch animation and development of this library, the workload is not small, thanks to support Hold Switchlayout * * If you want to customize the duration of the effect animation, please set switchlayout.animduration = 1000 in this four variables; * switchlayout.longanimduration = 2000; baseanimviews.animduration = 1000; * baseanimviews.longanimduration = 2000; Unit milliseconds. * * After switchlayout will be divided into my smartui library * * @author Tan dong (Tan Dong) 2014.12.28 * */public class Mainactivity extends Activity {Private Button Btn_ok, btn_1, Btn_2, Btn_3, Btn_4, Btn_5, Btn_6, Btn_7,btn_8, Btn_9, Btn_10, Btn_11, Btn_12, btn_13, Btn_ @Overrideprotected void OnCreate (Bundle savedinstancestate) {requestwindowfeature (window.feature_no_title); Super.oncreate (savedinstancestATE); Setcontentview (R.layout.activity_main); Initview ();//Set the activity effect animation into activity, The same can be extended to the Layout animation Switchlayout.getslidefrombottom (this, false,baseeffects.getquicktosloweffect ());//three parameters are (activity/ View, whether to close activity, special effects (can be empty)) Initlistener ();} private void Initlistener () {Btn_ok.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) { TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("key", 0); MainActivity.this.startActivity (in);}}); Btn_1.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 1); MainActivity.this.startActivity (in);}}); Btn_2.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 2); MainActivity.this.startActiVity (in);}}); Btn_3.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 3); MainActivity.this.startActivity (in);}}); Btn_4.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 4); MainActivity.this.startActivity (in);}}); Btn_5.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 5); MainActivity.this.startActivity (in);}}); Btn_6.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 6); MainActivity.this.startActivity(in);}}); Btn_7.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 7); MainActivity.this.startActivity (in);}}); Btn_8.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 8); MainActivity.this.startActivity (in);}}); Btn_9.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 9); MainActivity.this.startActivity (in);}}); Btn_10.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 10); MainActivity.this.startActivity (in);}); Btn_11.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 11); MainActivity.this.startActivity (in);}}); Btn_12.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 12); MainActivity.this.startActivity (in);}}); Btn_13.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 13); MainActivity.this.startActivity (in);}}); Btn_14.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent in = new Intent (mainactivity.this, Secondactivity.class); In.putextra ("Key", 14); MainActivity.this.startActiviTy (in);}}); private void Initview () {BTN_OK = (button) This.findviewbyid (R.ID.BTN_OK); btn_1 = (Button) This.findviewbyid (r.id.btn_1 ); btn_2 = (Button) This.findviewbyid (r.id.btn_2); btn_3 = (Button) This.findviewbyid (r.id.btn_3); btn_4 = (Button) This.findviewbyid (r.id.btn_4); btn_5 = (Button) This.findviewbyid (r.id.btn_5); btn_6 = (Button) This.findviewbyid ( R.id.btn_6) btn_7 = (Button) This.findviewbyid (r.id.btn_7); btn_8 = (Button) This.findviewbyid (r.id.btn_8); btn_9 = ( button) This.findviewbyid (r.id.btn_9), btn_10 = (button) This.findviewbyid (r.id.btn_10); btn_11 = (Button) This.findviewbyid (r.id.btn_11); Btn_12 = (Button) This.findviewbyid (R.id.btn_12); btn_13 = (Button) This.findviewbyid ( r.id.btn_13) btn_14 = (Button) This.findviewbyid (r.id.btn_14);}}

Package Com.tandong.swichlayoutdemo;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.view.keyevent;import Android.view.view;import Android.view.View.OnClickListener; Import Android.view.window;import Android.widget.imageview;import Com.tandong.swichlayout.baseeffects;import Com.tandong.swichlayout.swichlayoutinterface;import Com.tandong.swichlayout.switchlayout;import com.tandong.swichlayoutdemo.r;/** * switchlayout * * QQ 852041173 * * For Android to provide the iOS platform's own interface view switch animation and development of this library, the workload is not small, thanks to support switch Layout * * @author Tan dong (Tan Dong) 2014.12.28 * */public class Secondactivity extends Activity implements Swichlayoutinterf Ace {private Intent intent;private ImageView iv_back;private int key = 0; @Overrideprotected void onCreate (Bundle savedinst Ancestate) {requestwindowfeature (window.feature_no_title); super.oncreate (savedinstancestate); SetContentView ( R.layout.activity_second); initintent ();//Set the activity effect animation into the activity, which can be extended to the Layout animation setenterswichlayout ();} Private void Initintent () {intent = getintent (); key = Intent.getextras (). GetInt ("key"); Iv_back = (ImageView) This.findviewbyid ( R.id.iv_back); Iv_back.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) { Setexitswichlayout ();}});} public boolean onKeyDown (int keycode, keyevent event) {//press the return key when exiting activity's activity effect animation if (keycode = = Keyevent.keycode_ Back && event.getrepeatcount () = = 0) {setexitswichlayout (); return true;} Return Super.onkeydown (KeyCode, event);} @Overridepublic void Setenterswichlayout () {switch (key) {case 0:switchlayout.get3drotatefromleft (this, false, NULL); /three parameters (Activity/view, whether to close Activity, effect (nullable)) Break;case 1:switchlayout.getslidefrombottom (this, false, Baseeffects.getmoresloweffect ()); Break;case 2:switchlayout.getslidefromtop (this, false, Baseeffects.getrescrolleffect ()); Break;case 3:switchlayout.getslidefromleft (this, false, Baseeffects.getlinearintereffect ()); Break;case 4:switchlayout.getslidefromright (this, false, null); Break;case 5: SwitChlayout.getfadingin (this); Break;case 6:switchlayout.scalebig (this, false, null); Break;case 7: Switchlayout.flipupdown (this, false,baseeffects.getquicktosloweffect ()); Break;case 8: Switchlayout.scalebiglefttop (this, false, null); Break;case 9:switchlayout.getshakemode (this, false, NULL); Case 10:switchlayout.rotateleftcenterin (this, false, null); Break;case 11:switchlayout.rotatelefttopin (this, false, NULL); Break;case 12:switchlayout.rotatecenterin (this, false, null); Break;case 13: Switchlayout.scaletobighorizontalin (this, false, null); Break;case 14:switchlayout.scaletobigverticalin (This, false , null); break;default:break;}} @Overridepublic void Setexitswichlayout () {switch (key) {case 0:switchlayout.get3drotatefromright (this, true, NULL); Break;case 1:switchlayout.getslidetobottom (this, true,baseeffects.getmoresloweffect ()); Break;case 2: Switchlayout.getslidetotop (this, true,baseeffects.getrescrolleffect ()); Break;case 3:switchlayout.getslidetoleft ( This, True,baseeffects.getlinearintereffeCT ()); Break;case 4:switchlayout.getslidetoright (this, true, null); Break;case 5:switchlayout.getfadingout (This, true ); Break;case 6:switchlayout.scalesmall (this, true, null); Break;case 7:switchlayout.flipupdown (This, true, Baseeffects.getquicktosloweffect ()); Break;case 8:switchlayout.scalesmalllefttop (this, true, NULL); Break;case 9: Switchlayout.getshakemode (this, true, null); Break;case 10:switchlayout.rotateleftcenterout (this, true, NULL); Case 11:switchlayout.rotatelefttopout (this, true, null); Break;case 12:switchlayout.rotatecenterout (this, true, NULL) ; Break;case 13:switchlayout.scaletobighorizontalout (this, true, null); Break;case 14: Switchlayout.scaletobigverticalout (this, true, null); break;default:break;}}}

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Com.tandong.swichlayoutdemo "android:versioncode=" 1 "android:versionname=" 1.0 "> <uses -SDK android:minsdkversion= "one" android:targetsdkversion= "/> <application android:allowb" Ackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" Android:theme= "@st Yle/apptheme "> <activity android:name=" com.tandong.swichlayoutdemo.MainActivity "Andro Id:label= "@string/app_name" Android:theme= "@android: Style/theme.translucent" > <intent-filter&                Gt <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.catego Ry. LAUNCHER "/> </intent-filter> </activity> <activity android:name=" Co M.tandong.swichlaYoutdemo. Secondactivity "android:launchmode=" Singletask "Android:theme=" @android: Style/theme.translucent "        ; </activity> </application></manifest>




Android activity Toggle Animation Effect Library Switchlayout, view Toggle Animation Library, comparable to iOS

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.