GithubHelp home page GithubHelp logo

mibrahim017 / android-different-loading-animations Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rgocal/differentloadinganimations

0.0 1.0 0.0 812 KB

Different types of loading animations.

License: Apache License 2.0

Java 100.00%

android-different-loading-animations's Introduction

Loading animations

different types of loading animations.

===================================
Different types of loading animations.

"Animation is not the art of drawing that move but the art of movements that are drawn".

A good mobile app is often defined by fluid animation and a clean UI. Performance does matter, but what if its not intuitive to the user; it's rendered useless. A few trend setting mobile apps such as google plus, path, foursquare etc, are known for their amazing UI. These main stream apps have their own unique loading animations. My sole purpose of writing this article was to show how you can implement those loading animations and customize your own for your app.

##Screenshot

Loading


The Android framework provides two animation systems: [Property Animation](http://developer.android.com/guide/topics/graphics/prop-animation.html) (introduced in Android 3.0) and [View animation](http://developer.android.com/guide/topics/graphics/prop-animation.html#q=view animation). Both animation systems are viable options, but the property animation system, in general, is the preferred method to use,because it is more flexible and offers more features.

Property Animation

A property animation changes a property's (a field in an object) value over a specified length of time. To animate something, you specify the object property that you want to animate, such as an object's position on the screen, how long you want to animate it for, and what values you want to animate between.

Sample app shows how property animation can be implemented. Following points are covered:

PropertyValuesHolder myView_Y = PropertyValuesHolder.ofFloat(myView.TRANSLATION_Y, -40.0f);
PropertyValuesHolder myView_X = PropertyValuesHolder.ofFloat(myView.TRANSLATION_X, 0);
ObjectAnimator waveOneAnimator = ObjectAnimator.ofPropertyValuesHolder(myView, myView_X, myView_Y);
waveOneAnimator.setRepeatCount(-1);        // -1 for infinite
waveOneAnimator.setRepeatMode(ValueAnimator.REVERSE);
waveOneAnimator.setDuration(300);
waveOneAnimator.start();

* How to implement an animation.
PropertyValuesHolder myView_Y = PropertyValuesHolder.ofFloat(myView.TRANSLATION_Y, -40.0f);
PropertyValuesHolder myView_X = PropertyValuesHolder.ofFloat(myView.TRANSLATION_X, 0);
ObjectAnimator waveOneAnimator = ObjectAnimator.ofPropertyValuesHolder(myView, myView_X, myView_Y);

In the above example we are using `PropertyValuesHolder` class to animate Y-co ordinate of the view. Here we are translating Y-co ordinate by -40 and keeping X-coordinate as 0.
[ObjectAnimator](http://developer.android.com/reference/android/animation/ObjectAnimator.html#ObjectAnimator() is a subclass of `ValueAnimator`, provides support for animating properties on target view.

  • How to loop an animation.
waveOneAnimator.setRepeatCount(-1); // -1 for infinite

setRepeatCount(int n) this method is use to set animation count. Here -1 means infinte and 0 means only once. If n > 0 then then animation will be repeated n times. Another handy way to repeat an animation is by using listeners.

For example:

waveOneAnimator.addListener(new AnimatorListener() {

    		@Override
			public void onAnimationStart(Animator animation) {}

			@Override
			public void onAnimationRepeat(Animator animation) {}

			@Override
			public void onAnimationEnd(Animator animation) {
				waveOneAnimator.start();	// infinite loop.
			}

			@Override
			public void onAnimationCancel(Animator animation) {}
		});

  • How to run multiple animation's together or independently.

a. To animate sequentially :

        AnimatorSet animatorSet1 = new AnimatorSet();
		animatorSet1.playSequentially(valueAnimatorOne, valueAnimatorTwo, valueAnimatorThree); 
		animatorSet1.start();

b. To animate all animation at same time.

        AnimatorSet animatorSet1 = new AnimatorSet();
    	animatorSet1.playTogether(valueAnimatorOne, valueAnimatorTwo, valueAnimatorThree);
		animatorSet1.start();

android-different-loading-animations's People

Contributors

learnncode avatar thinknikhil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.