Prevent Click-through of Android ImageVIew? Prevent Click-through of Android ImageVIew? android android

Prevent Click-through of Android ImageVIew?


you can set the image to be

android:clickable="true"


Simply call rlTest.setClickable(false). This will prevent the click to be propagate to the children


There is a much cleaner way

You can use:

android:onClick="preventClicks"

in XML and in your Activity

public void preventClicks(View view) {}

This works with fragments.Example inside this Activity has multiple fragments overlapping one another, just by adding the XML attribute in the background of your fragment it will still call the Activity.preventClicks and will prevent touches on fragments behind it