Make animations no longer stiff: Facebook rebound Android Animation library Introduction

Source: Internet
Author: User

Official Site:http://facebook.github.io/rebound

Github:https://github.com/facebook/rebound

Rebound is a library of elastic animations from Facebook that makes animations look natural, like real-world physical motion, with powerful effects and parameters used by Facebook's origami.

There is a simple JS version of the official website to do the demo, if it is said Evernote, LinkedIn, flow and other applications are also using this animation library, will it appear more powerful?

 spring Spring = Mspringsystem. Createspring (). Setspringconfig (Springconfig.fromorigamitensi Onandfriction (86, 7)). AddListener (new Simplespringlistener () { @Override public void onspringupdate (Spring spring) {float Value = (float) spring.getcurrentvalue (); Viewhelper.settranslationx (view, value); } });

The short code above gives a view a natural, left-to-right entry to the rebound effect.

Similarly,

Spring spring = Mspringsystem. Createspring (). Setspringconfig (Springconfig.fromorigamitensionandfriction ( (7)). AddListener (new Simplespringlistener () { @Override public  VO ID onspringupdate (Spring spring) {Float value = (float) spring.getcurrentvalue (); float scale = 1f-value; Viewhelper.setscalex (Mitemiconviewlist.get (index), scale); Viewhelper.setscaley (Mitemiconviewlist.get (index), scale); } });

You can add a view to a small size and then a little rebound effect.

What if you want to do a lot of view chain animations? The rebound also provides the Springchain interface.

for (int i =0; i < Viewcount; i++) {Final View view =New View (context); View.setlayoutparams (New Tablelayout.layoutparams (ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT,1f)); Mspringchain.addspring (New Simplespringlistener () {@OverridePublicvoid Onspringupdate (Spring spring) {Float value = (float) spring.getcurrentvalue (); View.settranslationx (value); } });int color = (Integer) evaluator.evaluate ((float) I/(float) Viewcount, StartColor, EndColor); View.setbackgroundcolor (color); View.setontouchlistener (New Ontouchlistener () {@OverridePublicBoolean OnTouch (View V, motionevent event) {Return Handlerowtouch (V, event); } }); Mviews.add (view); Rootview.addview (view);} Getviewtreeobserver (). Addongloballayoutlistener (New Viewtreeobserver.ongloballayoutlistener () {@OverridePublicvoid Ongloballayout () {getviewtreeobserver (). Removeongloballayoutlistener (this); List<spring> springs = mspringchain.getallsprings (); for (int i = 0; I < springs.size (); i++) {springs.get (i). Setcurrentvalue (-mviews.get (i). GetWidth ());} postdelayed (new Runnable () { @Override public void run () {Mspringchain. Setcontrolspringindex (0). Getcontrolspring (). Setendvalue (0); }}, 500); }});

A view and view of the traction displacement animation effect was made.


Make animations no longer stiff: Facebook rebound Android Animation library Introduction

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.