Code example for ValueAnimator

Methods: addListeneraddUpdateListenersetDurationstart, setIntValues

0
		this.stopWidth = stopWidth;
		this.stopHeight = stopHeight;
		widthDifference = stopWidth - startWidth;
		heightDifference = stopHeight - startHeight;
 
		ValueAnimator valueAnimator = new ValueAnimator();
		valueAnimator.setDuration(durationTime);
		valueAnimator.setIntValues(new int[] { 0, 0 }); // the values are irrelevant
		valueAnimator.addUpdateListener(userAnimatorUpdateListener);
		valueAnimator.addListener(animatorListener);
		valueAnimator.start();
	} 
 
	private AnimatorUpdateListener userAnimatorUpdateListener = new AnimatorUpdateListener() {
		@Override 
		public void onAnimationUpdate(ValueAnimator valueAnimator) { 
			LayoutParams layoutParams = viewGroupLayout.getLayoutParams(); 
			if (stopWidth >= 0) { 
				layoutParams.width = (int) (startWidth + widthDifference 
						* valueAnimator.getCurrentPlayTime() / durationTime); 
Experience pair programming with AI  Get Codota for Java