Android Activity switches the animation effect library SwitchLayout, and views switch the animation library, which is comparable to IOS,

Source: Internet
Author: User
Tags types of extensions

Android Activity switches the animation effect library SwitchLayout, and views switch the animation library, which is comparable to IOS,


Because of the excellent experience of switching an animation on The View Interface of the APP developed by many developers on IOS, these are built-in in IOS, but the Android Activity and other view switching animations do not provide native, therefore, we have written an Android view switching animation special effect library comparable to IOS view switching animation! SwitchLayout! It can be said that it is the first in Android and the only powerful view switching animation library engine!


Author: Tan Dong

QQ: 852041173

Open Source project! We recommend using the jar package format!

The source code of the project library cannot be modified and released by the author.

If SwtichLayout is used in your project, we recommend that you enter the SwitchLayout library on the page of your APP to provide support! Thank you very much! If you think SwitchLayout is powerful, we recommend it to your friends.

If you have any suggestions, you can also send me feedback. The SwitchLayout library will be upgraded in time.


SwitchLayout 1.0jar package and Demo: http://pan.baidu.com/s/1dD6baLV

The source code will be hosted on Github in the near future


Now, let's take a look at the view switching special effects supported on the main interface! (This is Demo)

,




The Performance Engine is comparable to IOS.

In the list, each custom extension engine interface exposed by a special effect can expand about 8 special effects. So a total of about 105 special effects can be expanded! Strong enough!


Well, the general usage is as follows:

1. Import SwitchLayout1.0.jar or download the Open Source library.

2. Each Activity implements the implements SwichLayoutInterFace. This method is recommended. Two methods are implemented in the interface: setEnterSwichLayout (); and setExitSwichLayout (). The two methods are respectively set to enter the Activity animation and to exit the Activity animation.

Call setEnterSwichLayout () in onCreate (); Call setExitSwichLayout () in the Activity close operation; if necessary, intercept the return button in onKeyDown and call setExitSwichLayout ();


3. Specific special effect call (for example): SwitchLayout. getSlideFromBottom (this, false, BaseEffects. getMoreSlowEffect ());

// The three parameters are Activity/View, whether Activity is disabled, and special effect (can be empty). Each special effect supports 8 types of extensions, or you can leave the special effect empty.

4. Note that in the project registration list, the topic of each Activity must be set as a transparent topic. Android: theme = "@ android: style/Theme. Translucent", the API is above 11.

Next, paste the code in 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 ** this library is developed for Android by providing its own UI view switching animation on the IOS platform. Thanks for supporting SwitchLayout. ** if you want to customize the animation duration of a special effect, set SwitchLayout for the four variables. animDuration = 1000; * SwitchLayout. longAnimDuration = 2000; BaseAnimViewS. animDuration = 1000; * BaseAnimViewS. longAnimDuration = 2000. Unit: milliseconds. ** SwitchLayout will be divided into the following parts in 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, numbers, btn_6, btn_7, numbers, numbers, btn_10, btn_11, btn_12, btn_13, btn_14; @ define void onCreate (Bundle limit) {limit (Window. FEATURE_NO_TITLE); super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); initView (); // sets the Activity special effect animation to enter the Activity. Similarly, it expands to the layout animation SwitchLayout. getSlideFromBottom (this, false, BaseEffects. getQuickToSlowEffect (); // the three parameters are (Activity/View, whether to disable Activity, special effect (can be blank) 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 ** it takes a lot of effort to develop this library by providing Android with an UI view switch animation on the IOS platform, thanks for supporting SwitchLayout ** @ author Tan Dong (Tan Dong) 2014.12.28 **/public class SecondActivity extends Activity implements SwichLayoutInterFace {private Intent intent; private ImageView iv_back; private int key = 0; @ Overrideprotected void onCreate (Bundle savedInstanceState) {requestWindowFeature (Window. FEATURE_NO_TITLE); super. onCreate (savedInstanceState); setContentView (R. layout. activity_second); initIntent (); // sets the Activity special effect animation to enter the Activity. Similarly, it is 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) {// when you press the return key, exit the Activity special 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); // the three parameters are respectively (Activity/View, whether to disable Activity, special effect (can be blank) 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); break; 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. getspolicetobottom (this, true, BaseEffects. getMoreSlowEffect (); break; case 2: SwitchLayout. getsshortetotop (this, true, BaseEffects. getReScrollEffect (); break; case 3: SwitchLayout. getsappsetoleft (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); break; 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="11"        android:targetSdkVersion="19" />    <application        android:allowBackup="true"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/AppTheme" >        <activity            android:name="com.tandong.swichlayoutdemo.MainActivity"            android:label="@string/app_name"            android:theme="@android:style/Theme.Translucent" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>        <activity            android:name="com.tandong.swichlayoutdemo.SecondActivity"            android:launchMode="singleTask"            android:theme="@android:style/Theme.Translucent" >        </activity>    </application></manifest>




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.