Code example for RelativeLayout

Methods: getHeight, getWidth, setAnimationCacheEnabled, startAnimation

0
		} 
	} 
 
	private void applyRotation(int position, float start, float end) {
		// Find the center of the container 
		final float centerX = mContainer.getWidth() / 2.0f;
		final float centerY = mContainer.getHeight() / 2.0f;
 
		// Create a new 3D rotation with the supplied parameter 
		// The animation listener is used to trigger the next animation 
		AnimationSet set = new AnimationSet(false);
 
		final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end,
				centerX, centerY, 310.0f, true, true);
		rotation.setDuration(1000);
		rotation.setFillAfter(true);
		rotation.setInterpolator(new AccelerateInterpolator());
		// d当animation结束,或者重复的时候listener会得到通知 
		rotation.setAnimationListener(new DisplayNextView(position));
 
		Animation anim = AnimationUtils.loadAnimation(this, R.anim.myanim);
		// Animation anim3 = AnimationUtils.loadAnimation(this, R.anim.myanim3); 
		anim.setFillAfter(true);
		// anim3.setFillAfter(true); 
 
		anim.setStartOffset(1100);
		// anim3.setStartOffset(1100 + anim.getDuration()); 
 
		// set.addAnimation(anim); 
		set.addAnimation(rotation);
		// set.addAnimation(anim3); 
		set.setFillAfter(true);
 
		if (position == 0) {
			mContainer.startAnimation(set);
			mContainer.setAnimationCacheEnabled(true);
		} 
		if (position == 1) {
			mContainer2.startAnimation(set);
			mContainer2.setAnimationCacheEnabled(true);
		}