Show/Hide view with animation in android -


i want hide , show view animation after user touches on screen alternatively. have not idea how that. can me, please?

i hight of view here

int finalheight = listview.getheight();  valueanimator manimator = slideanimator(finalheight, 0); 

then hide layout

valueanimator animator = valueanimator.ofint(start, end);      animator.addupdatelistener(new valueanimator.animatorupdatelistener() {         @override         public void onanimationupdate(valueanimator valueanimator) {             // update height             int value = (integer) valueanimator.getanimatedvalue();              viewgroup.layoutparams layoutparams = listview                     .getlayoutparams();             layoutparams.height = value;              listview.setlayoutparams(layoutparams);         }     }); 

i want same animation here example

your hiding animation can this:

    objectanimator hideanim = objectanimator.offloat(v, "translationy", 0, -v.getheight());     hideanim.setduration(300);      hideanim.addlistener(new animator.animatorlistener() {         @override          public void onanimationstart(animator animation) {          }           @override          public void onanimationend(animator animator) {             view.setvisibility(view.invisible);         }          @override          public void onanimationrepeat(animator animation) {          }      }); 

your unhiding anim can this:

    objectanimator unhideanim = objectanimator.offloat(v, "translationy", -v.getheight, 0);     unhideanim.setduration(300); 

click listeners view:

v.setonclicklistener(new view.onclicklistener() {     @overrride     public void onclick(view view) {         if (v.getvisibility() == view.invisible) {             v.setvisibility(view.visible)             v.startanimation(unhideanim);         } else {             v.startanimation(hideanim);         }     } }); 

will work if view @ top of viewgroup.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -