Fix to enable click events on custom layout

This fix adds a condition to onlyadd the overlay if the layout is gallery. For custom views, overlay should not be there, because it interferes with the custom view when trying to capture the click event.