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
Post a Comment