I need to fadeout a view and I need to show it again after some user action.
So I did this :
view.animate().alpha(0).setDuration(duration).start();
on animation end I did :
view.setVisibility(View.GONE);
and then when I want to show it once again I do
view.setVisibility(View.VISIBLE);
after which the view is not visible for some reason.
currently the only way I found to solve this issue is by doing this on animation end :
view.animate().alpha(1).start();
view.setVisibility(View.GONE);
and this solves it.
Wanted to know if there's other way which is more elegant and a better practice. Thanks
再次显示视图时,需要将Alpha重置为1: view.setAlpha(1f)
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.