在Android中完成动画时如何隐藏视图? [英] How to hide view when animation done in android?

查看:367
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆