Start same animation for diffrent objects one after another in android -


i want start same animation buttons,but don't want start in same time want start 1 after another! used doesn't work!how can fix this? me please

pivate void animation(){     animation fadein= animationutils.loadanimation(this,r.anim.fadein_btn);     try{         btn_seasons.startanimation(fadein);         thread.sleep(250);     }catch (exception e){         return;     }     try{         btn_main_exit.startanimation(fadein);         thread.sleep(250);     }catch (exception e){         return;     }     try{         btn_main_about.startanimation(fadein);         thread.sleep(250);     }catch (exception e){         return;     }     try{         btn_main_send.startanimation(fadein);         thread.sleep(250);     }catch (exception e){         return;     } } 

* call animation method on oncreate method!

lets asumme have layout this:

<linearlayout     android:id="@+id/linear"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="horizontal"     >      <button         android:id="@+id/btn1"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"/>      <button         android:id="@+id/btn2"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"/>      <button         android:id="@+id/btn3"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"/>      <button         android:id="@+id/btn4"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"/>      <button         android:id="@+id/btn5"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"/>      <button         android:id="@+id/btn6"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"/> </linearlayout> 

this animate buttons 90ms delay 1 after scale animation , starting delay 800ms. if want animate of buttons need modify code bit suit own needs. it's example give idea.

 @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      final linearlayout linear = (linearlayout)findviewbyid(r.id.linear);      int delay;     (int = 0; < linear.getchildcount(); i++) {         delay=(i*90)+800;         view v = linear.getchildat(i);         if (v instanceof button) {             linear.getchildat(i).setscaley(0f);             linear.getchildat(i).setscalex(0f);             linear.getchildat(i).animate()                     .setinterpolator(new decelerateinterpolator(1.6f))                     .setstartdelay(delay)                     .setduration(400)                     .scaley(1f)                     .scalex(1f)                     .setlistener(new animatorlisteneradapter() {                         @override                         public void onanimationstart(animator animation) {                          }                          @override                         public void onanimationend(animator animation) {                          }                     })                     .start();         }      }  } 

Comments