Fade in not working but fade out Animation works on Android -
i use method show view need fade in or fade out animation
.
it works when pass false execute fade out animation when pass true, fade in doesn't execute, instead, appears after 500ms without animation;
private void setviewtransition(final boolean isvisible, final view view) { animation fadeanim; if (isvisible) { fadeanim = new alphaanimation(0.0f, 1.0f); if (view.getalpha() == 1.0f) { return; } } else { fadeanim = new alphaanimation(1.0f, 0.0f); if (view.getalpha() == 0.0f) { return; } } fadeanim.setduration(500); fadeanim.setanimationlistener(new animation.animationlistener() { @override public void onanimationstart(animation animation) { } @override public void onanimationend(animation animation) { if (isvisible) { view.setalpha(1.0f); } else { view.setalpha(0.0f); } } @override public void onanimationrepeat(animation animation) { } }); view.startanimation(fadeanim); }
it might related issue: android fade in not working never got answers...
what doing wrong ?
although i'm not entirely sure why way doesn't work. bit roundabout , more complicated needs to fade animation. here's concise way of doing instead (for api 12+).
private void setviewtransition(boolean isvisible, view view) { view.animate().alpha(isvisible ? 1.0f : 0.0f).setduration(500); }
Comments
Post a Comment