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