Bug 43295 - Errors with TapGestureRecognizer on ContentView with nested Layout in Android
Summary: Errors with TapGestureRecognizer on ContentView with nested Layout in Android
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-08-12 08:24 UTC by Arne De Vreese
Modified: 2016-08-16 07:35 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Test Project (192.28 KB, application/x-zip-compressed)
2016-08-12 08:24 UTC, Arne De Vreese

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Arne De Vreese 2016-08-12 08:24:27 UTC
Created attachment 17002 [details]
Test Project

## Description

TapGestureRecognizers on a ContentView does not always work in Android.

## Steps to reproduce

1. Launch the attached test project to an Android device or simulator. 

2. Tap the ContentViews

Expected result: an entry should be added in the StackLayout at the bottom, showing which View is tapped.

Actual result: for View 3 & 5 no entry is added on Android. This indicates that the assigned Command is not executed.

## Notes

The only difference between the examples affected by the bug (View 3 and 5) and the working examples View 2 and 4 is the BackgroundColor property being set on nested Layouts in the ContentView to which the TapGestureRecognizer is assigned.

The difference between View 3/5 and View 1 (which has a BackgroundColor set to the nested View, but shows the expected result), is that the nested View in View 3 and 5 is a Layout and View 1 only contains a Label.

In iOS the TapGestureRecognizer works for all Views in the sample project.
Comment 1 Rui Marinho 2016-08-12 14:46:41 UTC
Hi Arne, you need to set  InputTransparent="true" in your child views, so they don't intercept the tap gestures. 

<ContentView x:Name="cv3">
	<StackLayout Orientation="Horizontal" BackgroundColor="Red" InputTransparent="true">
		<Label Text="View 3: Label in StackLayout with BackgroundColor" />

You should also add to the others that do work as is the expected usage.
Comment 2 Arne De Vreese 2016-08-16 07:35:21 UTC
Hi Rui, thank you very much for your quick response. Setting the InputTransparent="true" indeed did the trick. 

However imho it's a bit confusing that the tap gestures are interecepted in some/most cases with InputTransparent="false" (in my example project: always on iOS and sometimes on Android), but not when a certain property (BackgroundColor) which, on first sight, has nothing to do with the tap gesture, is set.