How can I interact with elements behind a translucent Android app?

A very simple way of understanding stacking of views is to take a book (any book). Think of each page as a view.

Visibility

  • When you open the book you can see a page (Main View – VISIBLE)
  • When you turn the current page you can see the next page (INVISIBLE – Main View to show the next view. Remember you are only hiding the view, if you set the visibility to GONE this is equivalent to tearing of the current page to view the next page.)

Touch scenarios

  • Assume your first page is a wax page (translucent page similar to your translucent view) so you can see the underlying page
  • When you try to touch a figure on the second page, you are touching the first page although you can see the figure on the second page. It is impossible to touch the figure on the second page through the first page.

Don’t be disheartened, since it is a view you will be dealing with and not a paper you can still do what you want to do 🙂

  • Implement View.OnTouchListener for both your views
  • For translucent view any touch events you get, return FALSE in the method onTouch
  • Android will pass on the touch event to your underlying view.

Leave a Comment