在Android中完成动画时如何隐藏视图? [英] How to hide view when animation done in android?
问题描述
我有一个简单的 LinearLayout
,两个按钮并排放置。当需要时,它们应该从屏幕右侧滑入和滑出视图。我已经制作了动画,其余的工作都完成了,但是还有最后一个问题要解决。
I have a simple LinearLayout
with two Buttons side by side. They are supposed to slide into and out of view from the right side of the screen when needed. I have the animation working and the rest of the work is done, but I have one last problem to solve.
如何设置 LinearLayout
滑出动画完成后对 View.GONE
的可见性?我需要它消失在屏幕上。
How can I set the LinearLayout
's visibility to View.GONE
after the slide out animation is complete? I need it to disappear once it's of screen.
推荐答案
获取您的 Animation $的引用
做动画的对象。调用 Animation#setAnimationListener
,并在侦听器的 onAnimationEnd
方法中将可见性设置为 View.GONE
。
Grab a reference of your Animation
object doing the animation. Call Animation#setAnimationListener
and in the listener's onAnimationEnd
method set the visibility to View.GONE
.
这篇关于在Android中完成动画时如何隐藏视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!