The main layout and reverse layouts are two linear layouts, when you click the button, call the startanimation method.
boolean menuOut=false; public void startAnimation() { Animation anim; int w = mainLayout.getMeasuredWidth(); int h = mainLayout.getMeasuredHeight(); int left = (int) (mainLayout.getMeasuredWidth() * 0.80); if(!menuOut) { anim = new TranslateAnimation(0, -left, 0, 0); backLayout.setVisibility(View.VISIBLE); animParams.init(-left, 0, -left + w, h); } else { anim = new TranslateAnimation(0, left, 0, 0); animParams.init(0, 0, w, h); } anim.setDuration(400); anim.setAnimationListener(Sample.this); anim.setFillAfter(true); mainLayout.startAnimation(anim); }
AnimParams.java
public class AnimParams { int left, right, top, bottom; void init(int left, int top, int right, int bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; } }
Sravanya
source share