Code example for AlphaAnimation

Methods: setDurationsetFillAfter

0
	public void setSwipe(int swipe)
	{ 
		this.padding += swipe;
		View v = getChildAt(0);
		float a = (100 * Math.abs(padding) /getMeasuredWidth());
		AlphaAnimation alpha = new AlphaAnimation((100 - a) / 100f, (100 - a) / 100f);
		alpha.setDuration(0); // Make animation instant
		alpha.setFillAfter(true); // Tell it to persist after the animation ends
		v.startAnimation(alpha);
		requestLayout();
	} 
	 
	public void resetSwipe() 
	{ 
		this.padding = 0;
		View v = getChildAt(0);
		AlphaAnimation alpha = new AlphaAnimation(100, 100);
		alpha.setDuration(0); // Make animation instant// Tell it to persist after the animation ends
		v.startAnimation(alpha);
		requestLayout();
	}