Code example for RelativeLayout

Methods: getWidth, getX, setVisibility, startAnimation

0
			public void onClick(View v) {
				// TODO Auto-generated method stub 
				AnimationSet Close = new AnimationSet(true);
				Animation animHandleClose = new TranslateAnimation(
						Animation.RELATIVE_TO_PARENT, handle.getX(),
						Animation.RELATIVE_TO_PARENT, -panel.getWidth(),
						Animation.RELATIVE_TO_PARENT, 0.0f,
						Animation.RELATIVE_TO_PARENT, 0.0f);
				animHandleClose.setDuration(2000);
				animHandleClose.setFillAfter(true);
				// animation.setRepeatMode(Animation.RESTART); 
 
				// AnimationSet setPanelClose = new AnimationSet (true); 
				Animation animPanelClose = new TranslateAnimation(
						Animation.RELATIVE_TO_PARENT, panel.getX(),
						Animation.RELATIVE_TO_PARENT, -panel.getWidth(),
						Animation.RELATIVE_TO_PARENT, 0.0f,
						Animation.RELATIVE_TO_PARENT, 0.0f);
				animPanelClose.setDuration(2000);
				animPanelClose.setFillAfter(true);
				// animation.setRepeatMode(Animation.RESTART); 
 
				long timeClose = AnimationUtils.currentAnimationTimeMillis();
				animHandleClose.setStartTime(timeClose);
				animPanelClose.setStartTime(timeClose);
 
				Close.addAnimation(animPanelClose);
				Close.addAnimation(animHandleClose);
 
				panel.startAnimation(Close);
				handlein.startAnimation(Close);
				panel.setVisibility(View.GONE);
				handlein.setVisibility(View.INVISIBLE);
				handle.setVisibility(View.VISIBLE);
				open = false;
			} 
		});