Code example for AnimatorSet

Methods: addListener, playTogether, setDuration, start

0
		v.setTextColor(Color.BLACK);
		 
		l.addView(v);
		 
		AnimatorSet set = createAnimatorSet(v, 24, 110);
		set.start();
		set.addListener(new AnimatorListener(){
			@Override 
			public void onAnimationCancel(Animator arg0) {
				 
			} 
 
			@Override 
			public void onAnimationEnd(Animator arg0) {
				Intent returnIntent = new Intent();
				returnIntent.putExtra("result",s);
				setResult(RESULT_OK,returnIntent);  
				OverlayActivity.this.finish();
			} 
 
			@Override 
			public void onAnimationRepeat(Animator arg0) {
				 
			} 
 
			@Override 
			public void onAnimationStart(Animator arg0) {
				 
			} 
			 
		}); 
	} 
	 
	private AnimatorSet createAnimatorSet(View v, int x, int y) {
		ObjectAnimator animation1 = ObjectAnimator.ofFloat(v, "x", x);
		animation1.setDuration(1400);
		 
		ObjectAnimator animation2 = ObjectAnimator.ofFloat(v, "y", y);
		animation2.setDuration(1400);
 
		AnimatorSet set = new AnimatorSet();
		 
		set.playTogether(animation1, animation2);
		set.setDuration(750);
 
		return set;
	} 
}