Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will touch get detected while a View is in invisible state?

Tags:

android

I am using a CustomSlider in my app, and I have set it to be invisible.

When the user drags it or touches it (from top to bottom), my application needs to make the slider visible. Is this possible? How would I achieve it?

like image 696
Thamilvanan Avatar asked May 16 '12 05:05

Thamilvanan


2 Answers

I needed to do this with an ImageView and still get touch events. The solution was to setAlpha(0.0f) to hide the image and still get events.

like image 167
Robert Avatar answered Nov 10 '22 20:11

Robert


The touch event will be detected on the visible Views of your activity. While a View instance is hidden / invisible, you cannot interact with it.

You need a motion handler on the parent view / visible view to determine whether you need to show the slider (in case the motion is vertical) or not.

like image 32
rekaszeru Avatar answered Nov 10 '22 20:11

rekaszeru