├── .gitignore ├── .travis.yml ├── License ├── README.md ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── daimajia │ │ └── androidanimations │ │ ├── EffectAdapter.java │ │ ├── ExampleActivity.java │ │ └── MyActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ ├── activity_my.xml │ ├── example.xml │ └── item.xml │ ├── menu │ └── my.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── gradle-mvn-push.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── daimajia │ │ └── androidanimations │ │ └── library │ │ ├── BaseViewAnimator.java │ │ ├── Techniques.java │ │ ├── YoYo.java │ │ ├── attention │ │ ├── BounceAnimator.java │ │ ├── FlashAnimator.java │ │ ├── PulseAnimator.java │ │ ├── RubberBandAnimator.java │ │ ├── ShakeAnimator.java │ │ ├── StandUpAnimator.java │ │ ├── SwingAnimator.java │ │ ├── TadaAnimator.java │ │ ├── WaveAnimator.java │ │ └── WobbleAnimator.java │ │ ├── bouncing_entrances │ │ ├── BounceInAnimator.java │ │ ├── BounceInDownAnimator.java │ │ ├── BounceInLeftAnimator.java │ │ ├── BounceInRightAnimator.java │ │ └── BounceInUpAnimator.java │ │ ├── fading_entrances │ │ ├── FadeInAnimator.java │ │ ├── FadeInDownAnimator.java │ │ ├── FadeInLeftAnimator.java │ │ ├── FadeInRightAnimator.java │ │ └── FadeInUpAnimator.java │ │ ├── fading_exits │ │ ├── FadeOutAnimator.java │ │ ├── FadeOutDownAnimator.java │ │ ├── FadeOutLeftAnimator.java │ │ ├── FadeOutRightAnimator.java │ │ └── FadeOutUpAnimator.java │ │ ├── flippers │ │ ├── FlipInXAnimator.java │ │ ├── FlipInYAnimator.java │ │ ├── FlipOutXAnimator.java │ │ └── FlipOutYAnimator.java │ │ ├── rotating_entrances │ │ ├── RotateInAnimator.java │ │ ├── RotateInDownLeftAnimator.java │ │ ├── RotateInDownRightAnimator.java │ │ ├── RotateInUpLeftAnimator.java │ │ └── RotateInUpRightAnimator.java │ │ ├── rotating_exits │ │ ├── RotateOutAnimator.java │ │ ├── RotateOutDownLeftAnimator.java │ │ ├── RotateOutDownRightAnimator.java │ │ ├── RotateOutUpLeftAnimator.java │ │ └── RotateOutUpRightAnimator.java │ │ ├── sliders │ │ ├── SlideInDownAnimator.java │ │ ├── SlideInLeftAnimator.java │ │ ├── SlideInRightAnimator.java │ │ ├── SlideInUpAnimator.java │ │ ├── SlideOutDownAnimator.java │ │ ├── SlideOutLeftAnimator.java │ │ ├── SlideOutRightAnimator.java │ │ └── SlideOutUpAnimator.java │ │ ├── specials │ │ ├── HingeAnimator.java │ │ ├── RollInAnimator.java │ │ ├── RollOutAnimator.java │ │ ├── in │ │ │ ├── DropOutAnimator.java │ │ │ └── LandingAnimator.java │ │ └── out │ │ │ └── TakingOffAnimator.java │ │ ├── zooming_entrances │ │ ├── ZoomInAnimator.java │ │ ├── ZoomInDownAnimator.java │ │ ├── ZoomInLeftAnimator.java │ │ ├── ZoomInRightAnimator.java │ │ └── ZoomInUpAnimator.java │ │ └── zooming_exits │ │ ├── ZoomOutAnimator.java │ │ ├── ZoomOutDownAnimator.java │ │ ├── ZoomOutLeftAnimator.java │ │ ├── ZoomOutRightAnimator.java │ │ └── ZoomOutUpAnimator.java │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | /build 6 | # built application files 7 | *.apk 8 | *.ap_ 9 | 10 | # files for the dex VM 11 | *.dex 12 | 13 | # Java class files 14 | *.class 15 | .DS_Store 16 | 17 | # generated files 18 | bin/ 19 | gen/ 20 | Wiki/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Eclipse project files 26 | .classpath 27 | .project 28 | .settings/ 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | #Android Studio 34 | build/ 35 | 36 | # Intellij project files 37 | *.iml 38 | *.ipr 39 | *.iws 40 | .idea/ 41 | 42 | #gradle 43 | .gradle/ 44 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - tools 5 | - platform-tools 6 | - build-tools-25.0.2 7 | - android-25 8 | - extra-android-support 9 | - extra 10 | - extra-android-m2repository 11 | script: 12 | - ./gradlew assembleDebug -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 daimajia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android View Animations [![Build Status](https://travis-ci.org/daimajia/AndroidViewAnimations.svg)](https://travis-ci.org/daimajia/AndroidViewAnimations) 2 | 3 | One day, I saw [an iOS library](https://github.com/ArtFeel/AFViewShaker), which is a view shaker, it's very beautiful. I think Android also need one, and should be better. 4 | 5 | So, I started to collect animation effects... and in two days, this project born. 6 | 7 | # Demo 8 | 9 | ![](http://ww3.sinaimg.cn/mw690/610dc034gw1ej75mi2w77g20c30jb4qr.gif) 10 | 11 | [Download Demo](https://github.com/daimajia/AndroidViewAnimations/releases/download/v1.1.2/AndroidViewAnimations-1.1.2.apk) 12 | # Usage 13 | 14 | > Since Version 2.0, NineOldAndroids has been removed. Thanks Jake Wharton. 15 | 16 | For making animations more real, I created another project named [Android Easing Functions](https://github.com/daimajia/AnimationEasingFunctions) which is an implementations of [easing functions](http://easings.net/) on Android. So, we need to dependent that project. 17 | 18 | ## Step 1 19 | 20 | #### Gradle 21 | ```groovy 22 | dependencies { 23 | implementation 'com.daimajia.androidanimations:library:2.4@aar' 24 | } 25 | ``` 26 | #### Maven 27 | 28 | ```xml 29 | 30 | com.daimajia.androidanimation 31 | library 32 | 2.4 33 | 34 | ``` 35 | 36 | ## Step 2 37 | 38 | Just like play Yo-yo. 39 | 40 | ```java 41 | YoYo.with(Techniques.Tada) 42 | .duration(700) 43 | .repeat(5) 44 | .playOn(findViewById(R.id.edit_area)); 45 | ``` 46 | 47 | ### Effects 48 | #### Attension 49 | `Flash`, `Pulse`, `RubberBand`, `Shake`, `Swing`, `Wobble`, `Bounce`, `Tada`, `StandUp`, `Wave` 50 | 51 | #### Special 52 | `Hinge`, `RollIn`, `RollOut`,`Landing`,`TakingOff`,`DropOut` 53 | 54 | #### Bounce 55 | `BounceIn`, `BounceInDown`, `BounceInLeft`, `BounceInRight`, `BounceInUp` 56 | 57 | #### Fade 58 | `FadeIn`, `FadeInUp`, `FadeInDown`, `FadeInLeft`, `FadeInRight` 59 | 60 | `FadeOut`, `FadeOutDown`, `FadeOutLeft`, `FadeOutRight`, `FadeOutUp` 61 | 62 | #### Flip 63 | `FlipInX`, `FlipOutX`, `FlipOutY` 64 | 65 | #### Rotate 66 | `RotateIn`, `RotateInDownLeft`, `RotateInDownRight`, `RotateInUpLeft`, `RotateInUpRight` 67 | 68 | `RotateOut`, `RotateOutDownLeft`, `RotateOutDownRight`, `RotateOutUpLeft`, `RotateOutUpRight` 69 | 70 | #### Slide 71 | `SlideInLeft`, `SlideInRight`, `SlideInUp`, `SlideInDown` 72 | 73 | `SlideOutLeft`, `SlideOutRight`, `SlideOutUp`, `SlideOutDown` 74 | 75 | #### Zoom 76 | `ZoomIn`, `ZoomInDown`, `ZoomInLeft`, `ZoomInRight`, `ZoomInUp` 77 | 78 | `ZoomOut`, `ZoomOutDown`, `ZoomOutLeft`, `ZoomOutRight`, `ZoomOutUp` 79 | 80 | Welcome contribute your amazing animation effect. :-D 81 | 82 | # Thanks 83 | 84 | - [AFViewShaker](https://github.com/ArtFeel/AFViewShaker) 85 | - [Animate.css](https://github.com/daneden/animate.css) 86 | 87 | # Why YoYo? 88 | 89 | YoYo is a [toy](https://en.wikipedia.org/wiki/Yo-yo), with a lot of [Techniques](./library/src/main/java/com/daimajia/androidanimations/library/Techniques.java). 90 | 91 | # About me 92 | 93 | (2013) 94 | A student in mainland China. 95 | 96 | Welcome to [offer me an internship](mailto:daimajia@gmail.com). 97 | If you have any new idea about this project, feel free to [contact me](mailto:daimajia@gmail.com). 98 | 99 | (2019) 100 | Five years later, now I become an investment associate in China. 101 | 102 | Welcome to send your business plan to [me](mailto:daimajia@gmail.com). Maybe I would have a better understanding on your startup project than others. Trust me. 103 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | google() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:4.0.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | google() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION.toInteger() 5 | 6 | defaultConfig { 7 | applicationId GROUP 8 | minSdkVersion MIN_SDK_VERSION.toInteger() 9 | targetSdkVersion TARGET_SDK_VERSION.toInteger() 10 | versionCode VERSION_CODE.toInteger() 11 | versionName VERSION_NAME 12 | } 13 | 14 | buildTypes { 15 | release { 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | lintOptions{ 21 | abortOnError false 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation project(':library') 28 | } 29 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /demo/src/main/java/com/daimajia/androidanimations/EffectAdapter.java: -------------------------------------------------------------------------------- 1 | package com.daimajia.androidanimations; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.TextView; 9 | 10 | import com.daimajia.androidanimations.library.Techniques; 11 | 12 | public class EffectAdapter extends BaseAdapter { 13 | 14 | private Context mContext; 15 | 16 | public EffectAdapter(Context context){ 17 | mContext = context; 18 | } 19 | 20 | @Override 21 | public int getCount() { 22 | return Techniques.values().length; 23 | } 24 | 25 | @Override 26 | public Object getItem(int position) { 27 | return Techniques.values()[position].getAnimator(); 28 | } 29 | 30 | @Override 31 | public long getItemId(int position) { 32 | return position; 33 | } 34 | 35 | @Override 36 | public View getView(final int position, View convertView, ViewGroup parent) { 37 | View v = LayoutInflater.from(mContext).inflate(R.layout.item,null,false); 38 | TextView t = (TextView)v.findViewById(R.id.list_item_text); 39 | Object o = getItem(position); 40 | int start = o.getClass().getName().lastIndexOf(".") + 1; 41 | String name = o.getClass().getName().substring(start); 42 | t.setText(name); 43 | v.setTag(Techniques.values()[position]); 44 | return v; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /demo/src/main/java/com/daimajia/androidanimations/ExampleActivity.java: -------------------------------------------------------------------------------- 1 | package com.daimajia.androidanimations; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | 8 | import com.daimajia.androidanimations.library.Techniques; 9 | import com.daimajia.androidanimations.library.YoYo; 10 | 11 | public class ExampleActivity extends Activity { 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.example); 16 | 17 | final TextView t = (TextView) findViewById(R.id.notice); 18 | t.setText("Please input your Email and Password"); 19 | 20 | findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() { 21 | @Override 22 | public void onClick(View v) { 23 | 24 | YoYo.with(Techniques.Tada) 25 | .duration(700) 26 | .playOn(findViewById(R.id.edit_area)); 27 | 28 | t.setText("Wrong password!"); 29 | } 30 | }); 31 | 32 | final TextView t2 = (TextView) findViewById(R.id.notice2); 33 | t2.setText("Please input your Email and Password"); 34 | 35 | findViewById(R.id.submit2).setOnClickListener(new View.OnClickListener() { 36 | @Override 37 | public void onClick(View v) { 38 | 39 | YoYo.with(Techniques.Shake).playOn(findViewById(R.id.edit_area2)); 40 | 41 | t2.setText("Wrong password!"); 42 | } 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /demo/src/main/java/com/daimajia/androidanimations/MyActivity.java: -------------------------------------------------------------------------------- 1 | package com.daimajia.androidanimations; 2 | 3 | import android.animation.Animator; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | import android.view.animation.AccelerateDecelerateInterpolator; 11 | import android.widget.AdapterView; 12 | import android.widget.ListView; 13 | import android.widget.Toast; 14 | 15 | import com.daimajia.androidanimations.library.Techniques; 16 | import com.daimajia.androidanimations.library.YoYo; 17 | 18 | public class MyActivity extends Activity { 19 | 20 | private ListView mListView; 21 | private EffectAdapter mAdapter; 22 | private View mTarget; 23 | private YoYo.YoYoString rope; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_my); 29 | 30 | mListView = (ListView) findViewById(R.id.list_items); 31 | mTarget = findViewById(R.id.hello_world); 32 | 33 | mAdapter = new EffectAdapter(this); 34 | mListView.setAdapter(mAdapter); 35 | 36 | mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 37 | @Override 38 | public void onItemClick(AdapterView parent, View view, int position, long id) { 39 | if (rope != null) { 40 | rope.stop(true); 41 | } 42 | Techniques technique = (Techniques) view.getTag(); 43 | rope = YoYo.with(technique) 44 | .duration(1200) 45 | .repeat(YoYo.INFINITE) 46 | .pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT) 47 | .interpolate(new AccelerateDecelerateInterpolator()) 48 | .withListener(new Animator.AnimatorListener() { 49 | @Override 50 | public void onAnimationStart(Animator animation) { 51 | 52 | } 53 | 54 | @Override 55 | public void onAnimationEnd(Animator animation) { 56 | } 57 | 58 | @Override 59 | public void onAnimationCancel(Animator animation) { 60 | Toast.makeText(MyActivity.this, "canceled previous animation", Toast.LENGTH_SHORT).show(); 61 | } 62 | 63 | @Override 64 | public void onAnimationRepeat(Animator animation) { 65 | 66 | } 67 | }) 68 | .playOn(mTarget); 69 | } 70 | }); 71 | findViewById(R.id.hello_world).setOnClickListener(new View.OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | if (rope != null) { 75 | rope.stop(true); 76 | } 77 | } 78 | }); 79 | } 80 | 81 | @Override 82 | public void onWindowFocusChanged(boolean hasFocus) { 83 | if (hasFocus) { 84 | rope = YoYo.with(Techniques.FadeIn).duration(1000).playOn(mTarget);// after start,just click mTarget view, rope is not init 85 | } 86 | } 87 | 88 | 89 | @Override 90 | public boolean onCreateOptionsMenu(Menu menu) { 91 | // Inflate the menu; this adds items to the action bar if it is present. 92 | getMenuInflater().inflate(R.menu.my, menu); 93 | return true; 94 | } 95 | 96 | @Override 97 | public boolean onOptionsItemSelected(MenuItem item) { 98 | // Handle action bar item clicks here. The action bar will 99 | // automatically handle clicks on the Home/Up button, so long 100 | // as you specify a parent activity in AndroidManifest.xml. 101 | int id = item.getItemId(); 102 | if (id == R.id.action_settings) { 103 | startActivity(new Intent(this, ExampleActivity.class)); 104 | return true; 105 | } 106 | return super.onOptionsItemSelected(item); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/AndroidViewAnimations/6a35c466d23e49c5cd174289ebe8d9ccdbc69044/demo/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/AndroidViewAnimations/6a35c466d23e49c5cd174289ebe8d9ccdbc69044/demo/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/AndroidViewAnimations/6a35c466d23e49c5cd174289ebe8d9ccdbc69044/demo/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/AndroidViewAnimations/6a35c466d23e49c5cd174289ebe8d9ccdbc69044/demo/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_my.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 26 | 27 | 32 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/example.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 18 | 19 | 23 | 24 | 28 | 29 | 30 | 35 | 36 | 40 | 41 |