Android RelativeLayout height animation -


i looking height animation relativelayout. should starting base value height of layout. trying write easyandroidanimation library. not succeed. below code attached. bouncing base. need smooth.

new bounceanimation(this.layoutgraph)            .setbouncedistance(50)     .setnumofbounces(5)     .setduration(500)     .animate(); 

also looking easy have use approach many layouts:

layout.startfrom(basevalue) layout.to(height of layout) layout.animate() 

any appreciated.

code adding*

as requested please find below code trying.

i calling animation calling below code.

  expand(this.mfirstgraph); 

expand method

   public void expand(final view v) {              v.measure(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.wrap_content);              int = (int)(0.075f * this.mwidthscreen);             //this.mfirstgraph.getlayoutparams().height = i;             int length=(int)(0.425f * this.mwidthscreen * (this.maxtemp - this.mweathermodel.mweekhightemperatures[0]) / this.ratiotemp);             final int targetheight = i+ length;              log.e("basic5", "targetheight: "+targetheight);              // older versions of android (pre api 21) cancel animations views height of 0.             v.getlayoutparams().height = 1;             v.setvisibility(view.visible);             animation = new animation()             {                 @override                 protected void applytransformation(float interpolatedtime, transformation t) {                     v.getlayoutparams().height = interpolatedtime == 1                             ? linearlayout.layoutparams.wrap_content                             : (int)(targetheight * interpolatedtime);                     v.requestlayout();                 }                  @override                 public boolean willchangebounds() {                     return true;                 }                  public void animate() {                     // todo auto-generated method stub                  }             };              // 1dp/ms             //a.setduration((int) (targetheight / v.getcontext().getresources().getdisplaymetrics().density));             a.setduration(2000);             log.e("basic5", "duration value: "+ (int) (targetheight / v.getcontext().getresources().getdisplaymetrics().density));             a.setinterpolator(new accelerateinterpolator(3));             v.startanimation(a);         }              public void collapse(final view v) {              final int initialheight = v.getmeasuredheight();              animation = new animation()             {                 @override                 protected void applytransformation(float interpolatedtime, transformation t) {                     if(interpolatedtime == 1){                         v.setvisibility(view.gone);                     }else{                         v.getlayoutparams().height = initialheight - (int)(initialheight * interpolatedtime);                         v.requestlayout();                     }                   }                    @override                 public boolean willchangebounds() {                     return true;                 }                    public void animate() {                     // todo auto-generated method stub                  }             };               // 1dp/ms              //a.setduration((int)(initialheight / v.getcontext().getresources().getdisplaymetrics().density));             a.setduration(200);             //a.setinterpolator(new decelerateinterpolator());              v.startanimation(a);         } 

problems identified currently

  1. the animation not smooth.
  2. height not proper. working on it.

maybe basic example you:

   public void expand(final view v) {      v.measure(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.wrap_content);     final int targetheight = v.getmeasuredheight();      // older versions of android (pre api 21) cancel animations views height of 0.     v.getlayoutparams().height = 1;     v.setvisibility(view.visible);     animation = new animation()     {         @override         protected void applytransformation(float interpolatedtime, transformation t) {             v.getlayoutparams().height = interpolatedtime == 1                     ? linearlayout.layoutparams.wrap_content                     : (int)(targetheight * interpolatedtime);             v.requestlayout();         }          @override         public boolean willchangebounds() {             return true;         }     };      // 1dp/ms     a.setduration((int) (targetheight / v.getcontext().getresources().getdisplaymetrics().density));     //a.setinterpolator(new accelerateinterpolator(3));     v.startanimation(a); }      public void collapse(final view v) {      final int initialheight = v.getmeasuredheight();      animation = new animation()     {         @override         protected void applytransformation(float interpolatedtime, transformation t) {             if(interpolatedtime == 1){                 v.setvisibility(view.gone);             }else{                 v.getlayoutparams().height = initialheight - (int)(initialheight * interpolatedtime);                 v.requestlayout();             }           }            @override         public boolean willchangebounds() {             return true;         }     };       // 1dp/ms      a.setduration((int)(initialheight / v.getcontext().getresources().getdisplaymetrics().density));     //a.setinterpolator(new decelerateinterpolator());     v.startanimation(a); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -