Android library to create easily cool animations -


i know cool library cool object animations in css, http://daneden.github.io/animate.css/

is there similar thing in android ? mean, library make animations easily.

thank you

creating animations easy. don't need library that. there 2 options fit situations, there other ways animate stuff these important ones:

  • view animations
  • object animator

there not of difference between 2 in terms of how used can different things.

1) view animations:

for view animation first have write animation xml. in describe animation should , how long lasts. can of course create animations programmatically, creating them in xml preferable in situations. example here 2 animation xmls, 1 slides view down top , other fades view out.

slide down:

<set xmlns:android="http://schemas.android.com/apk/res/android">     <translate             android:fromydelta="-100%"             android:toydelta="0%"             android:duration="1000"/> </set> 

fade out:

<set xmlns:android="http://schemas.android.com/apk/res/android">     <alpha             android:fromalpha="1"             android:toalpha="0"             android:duration="700"/> </set> 

than have load animation this:

animation slide = animationutils.loadanimation(getapplicationcontext(), r.anim.slide_down); 

and can apply animation view this:

linearlayout.startanimation(slide); 

you can combine animations in 1 xml, put multiple translate/alpha/etc. tags 1 set tag. can delay start of 1 animation in set setting startoffset this:

android:startoffset="500" 

for completeness: how create fade out animation programatically:

animation fadeout = new alphaanimation(1, 0); fadeout.setstartoffset(offset); fadeout.setduration(duration); 

2) object animator:

object animators can again created in code , xml, xml in cases preferable. fade out animation object animator:

<objectanimator xmlns:android="http://schemas.android.com/apk/res/android"                 android:interpolator="@android:anim/linear_interpolator"                 android:propertyname="alpha"                 android:valuetype="floattype"                 android:valuefrom="1.0"                 android:valueto="0.0"                 android:duration="1000" /> 

object animators may bit more complicated in beginning, there not of difference in xml. 1 thing arguably makes objectanimators preferable view animations objectanimators potentially lot more powerful can animate pretty property of object. example following animation rotate view around it's y axis , not many people know possible:

<objectanimator xmlns:android="http://schemas.android.com/apk/res/android"                 android:interpolator="@android:anim/accelerate_decelerate_interpolator"                 android:propertyname="rotationy"                 android:valuetype="floattype"                 android:valuefrom="0.0"                 android:valueto="360.0"                 android:duration="5000"/> 

and how create same animation programatically:

objectanimator animation = objectanimator.offloat(view, "rotationy", 0.0f, 360f); animation.setduration(5000); animation.setinterpolator(new acceleratedecelerateinterpolator()); animation.start(); 

the result looks this:

enter image description here

you can apply objectanimator animation xml this:

animatorset set = (animatorset) animatorinflater.loadanimator(getactivity(), r.animator.rotate_axis_y); set.settarget(targetview); set.start(); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -