android View with View.GONE 仍然接收 onTouch 和 onClick [英] android View with View.GONE still receives onTouch and onClick

查看:24
本文介绍了android View with View.GONE 仍然接收 onTouch 和 onClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我很困惑:

据我所知,带有 setVisibility(View.GONE); 的视图;不应再收到任何触摸或点击事件.我的布局有两个部分,它们将可见或消失,因此一次只有其中一个可见和可用,但 View.GONE 不能解决问题.正如预期的那样,我看不到 GONE 视图,但它仍然对 onClick 做出反应(并消耗另一个视图应该获得的事件).

As far as I have read, a view with setVisibility(View.GONE); should not receive any more touch- or click events. My layout has two parts, which will be visible or gone so that only one of them is visible and usable at a time but View.GONE doesn't do the trick. I can't see the GONE view, as expected, but it still reacts to onClick (and consumes the event the other view should get).

你能帮我吗?

可能感兴趣:当我开始我的项目时,一个视图消失了,另一个可见.这次它会按预期工作(基本上忽略了 GONE 视图),但是在通过代码设置 View.GONE 后它会停止工作.

推荐答案

您是否可能使用动画来显示/隐藏视图?当我使用具有 android:fillEnabled="true" android:fillAfter="true" 的动画时,我会出现这种行为不明白,似乎是一个错误 - 如果我使用没有 fillEnabled/fillAfter 的动画,一切都按预期工作......

Do you maybe use animations to show/hide the views? I get this behaviour when I use animations that have android:fillEnabled="true" android:fillAfter="true" Don't understand it, and seems like a bug - if I use animations without fillEnabled/fillAfter, all works as expected...

这篇关于android View with View.GONE 仍然接收 onTouch 和 onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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