Android Animation Alpha Android Animation Alpha android android

Android Animation Alpha


Try this

AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);animation1.setDuration(1000);animation1.setStartOffset(5000);animation1.setFillAfter(true);iv.startAnimation(animation1);


Might be a little late, but found a lovely solution in the android docs.

//In transition: (alpha from 0 to 0.5)view.setAlpha(0f);view.setVisibility(View.VISIBLE);view.animate()   .alpha(0.5f)   .setDuration(400)   .setListener(null);//Out transition: (alpha from 0.5 to 0)view.setAlpha(0.5f)view.animate()   .alpha(0f)   .setDuration(400)   .setListener(new AnimatorListenerAdapter() {           @Override           public void onAnimationEnd(Animator animation) {           view.setVisibility(View.GONE);         }    });


Kotlin Version

Simply use ViewPropertyAnimator like this:

iv.alpha = 0.2fiv.animate().apply {    interpolator = LinearInterpolator()    duration = 500    alpha(1f)    startDelay = 1000    start()}