Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Android view overlay not preventing clicking on controls behind it

Hey all I am trying to figure out what it is I am doing incorrectly since this does not seem to block my controls that are behind the view overlay.

This is my xml layout code:

<RelativeLayout>
   [all controls code here]
   <View
      android:layout_width="match_parent"
      android:layout_height="378dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true"
      android:layout_marginBottom="107dp"
      android:background="#86000000"
      android:elevation="2000dp" 
   />
</RelativeLayout>

and from the preview it is covering everything:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

But when I go and run it – I am able to click on the controls in the background as if the overlay was not even there…

What would I be missing here in order for it to block those controls behind it?

enter image description here

>Solution :

By default, a View does not handle touch events. Whether by making it clickable via android:clickable="true", adding a TouchListener, or something, you need to teach the View to handle touch events.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading