Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android View with View.GONE still receives onTouch and onClick

This is confusing me:

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).

Can you help me?

Maybe of interest: When I start my project one view is GONE, the other visible. This time it will work as expected (the GONE view is basically ignored), but after setting View.GONE through the code it'll stop working.

like image 679
ShadowMare Avatar asked Jan 18 '11 20:01

ShadowMare


2 Answers

If you set setVisibility(View.GONE) after some animation (fade out, for example), then try clearing the animation with clearAnimation(). This is what helped me.

like image 30
Pavel Alexeev Avatar answered Sep 23 '22 00:09

Pavel Alexeev


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...

like image 175
edovino Avatar answered Sep 23 '22 00:09

edovino