How to achieve sliding animation from top to bottom in Android(need to push the content below as this animation happens)? -


my layout have following things:

  1. i have title (a linear layout)

  2. the first content block (a relative layout in gone state now)

  3. the second content block (again relative layout visible)

i need animate first content block top bottom while pushing second content block below in same phase first content block moving.

i tried many methods. in things second content block visble @ place , first content block moving upto top. kindly give me suggestions.

you need give id layouts , create animation.

here sample code.

public void slidetoabove() {         animation slide = null;         slide = new translateanimation(animation.relative_to_self, 0.0f,                 animation.relative_to_self, 0.0f, animation.relative_to_self, 0.0f,                 animation.relative_to_self, -2.0f);          slide.setduration(400);         slide.setfillafter(true);         slide.setfillenabled(true);         rl_footer.startanimation(slide);          slide.setanimationlistener(new animationlistener() {              @override             public void onanimationstart(animation animation) {              }              @override             public void onanimationrepeat(animation animation) {             }              @override             public void onanimationend(animation animation) {                  rl_footer.clearanimation();                  relativelayout.layoutparams lp = new relativelayout.layoutparams(                         layoutparams.match_parent, 200);                 // lp.setmargins(0, 0, 0, 0);                 lp.addrule(relativelayout.align_parent_left);                 lp.addrule(relativelayout.align_parent_bottom);                 rl_footer.setlayoutparams(lp);              }          });      }      public void slidetodown() {         animation slide = null;         slide = new translateanimation(animation.relative_to_self, 0.0f,                 animation.relative_to_self, 0.0f, animation.relative_to_self, 0.0f,                 animation.relative_to_self, 1.0f);          slide.setduration(400);         slide.setfillafter(true);         slide.setfillenabled(true);         rl_footer.startanimation(slide);          slide.setanimationlistener(new animationlistener() {              @override             public void onanimationstart(animation animation) {              }              @override             public void onanimationrepeat(animation animation) {             }              @override             public void onanimationend(animation animation) {                  rl_footer.clearanimation();                  relativelayout.layoutparams lp = new relativelayout.layoutparams(                         layoutparams.match_parent, 70);                 // lp.addrule(relativelayout.align_parent_left);                 lp.addrule(relativelayout.align_parent_bottom);                 rl_footer.setlayoutparams(lp);              }          });      } 

where rl_footer , header id's of layout visible user. can call

 button.setonclicklistener(new onclicklistener() {                  @override                 public void onclick(view v) {                      iv_header.setimageresource(r.drawable.android);                     iv_header.setpadding(0, 10, 0, 0);                     slidetoabove();                  }             }); 

on button click or touch

regards


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -