android - layoutParams not changing -


i trying animate horizontal list item dismiss alpha animation works , layoutparam values decrease on time reason doesn't change actual height of list item.

@override protected void applytransformation(float interpolatedtime, transformation t) {     final int initialheight = view.getmeasuredheight();       if(interpolatedtime == 1){          imageadapter.remove(view, position);       }else{          view.getlayoutparams().height = initialheight - (int)(initialheight * interpolatedtime);         view.setalpha(1 - interpolatedtime);         system.out.println("  v height = " + view.getheight());         system.out.println("  v layoutparams = " + view.getlayoutparams().height);         view.forcelayout();         view.invalidate();         view.requestlayout();      } } 

this in getview method of imadeadapter , binbtn button touch remove listitem

      binbtn.setontouchlistener(new ontouchlistener() {           @override         public boolean ontouch(view v, motionevent event) {             // todo auto-generated method stub                     if (event.getaction() == motionevent.action_up)                       {                        view vp = (view) v.getparent();                  squeezeanimation ani = new squeezeanimation(this,vp,position);                 ani.setduration(1000);                 v.startanimation(ani); 

change code after tanis' answer still same problem, getheight() prints 674 , getlayoutparams().height prints 100

         else{          relativelayout.layoutparams lps = new relativelayout.layoutparams(100, 100);          view.setlayoutparams(lps);         view.requestlayout();          system.out.println("  v height = " + view.getheight());         system.out.println("  v layoutparams = " + view.getlayoutparams().height); 

as side note in getview method of imageadapter , changes height of view, , ive tried passing in backgroundfilliv animate still doesnt work

  view backgroundfilliv =  gridview.findviewbyid(r.id.backroundfillbar);        double mult =  products.get(position).value/ products.get(0).value;        backgroundfilliv.getlayoutparams().height = (int) ( (((bottleheight+20)*0.95)/mult));  

you need call setlayoutparams() @ point save changes layoutparams.

for example:

layoutparams lps = view.getlayoutparams(); lps.height = initialheight - (int)(initialheight * interpolatedtime); view.setalpha(1 - interpolatedtime); view.setlayoutparams(lps); 

this because getlayoutparams() method returning copy of layoutparams reference, not reference layoutparams themselves. there bit more in-depth discussion on @ does java return reference or value.


Comments