Android doesn't animate alpha if it's initially zero
Try something like this:
mRelativeLayout.setAlpha(0f); mRelativeLayout.animate().alpha(1f).setDuration(500).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mRelativeLayout.setVisibility(View.VISIBLE); //OR mRelativeLayout.setAlpha(1f); } });
I faced same issue where indicatorContainer
is ImageButton
.Below code fixes this very, very annoying issue...
// XXX: Does not work if just 0. It calls `ImageView#setAlpha(int)` deprecated method.indicatorContainer.setAlpha(0.0f);ViewCompat.animate(indicatorContainer).alpha(1);
One can try following, a more simple way:
view.animate().alpha(1).setDuration(ANIMATION_DURATION);