Bug 39818 - TapGestureRecognizer only responding to tap on a very specific section of a label
Summary: TapGestureRecognizer only responding to tap on a very specific section of a l...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.1.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-21 19:16 UTC by Cody Beyer (MSFT)
Modified: 2017-06-02 18:48 UTC (History)
4 users (show)

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


Attachments
Sample (376.87 KB, application/zip)
2016-03-21 19:16 UTC, Cody Beyer (MSFT)
Details


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:
Status:
RESOLVED ANSWERED

Description Cody Beyer (MSFT) 2016-03-21 19:16:03 UTC
Created attachment 15477 [details]
Sample

#Description

The following sample has a TapGestureRecognizer attached to each label, however tapping the label does not fire the event. Only if you tap a very specific part of the label, does the event fire.

# Sample

Attached

# Video

https://www.dropbox.com/s/e2euphwgsa7p6c3/lblTapMiss.mov?dl=0

# Steps to Reproduce

1. Download sample
2. Deploy to Android
3. Attempt to tap “Info Plus”

# Expected Results

Message box should appear stating that the tap has occurred

# Actual Results

Noting happens, unless you hit right above the “i” of “info”

# Versions

=== Xamarin Studio ===

Version 6.0 (build 4801)
Installation UUID: c6c42496-bf80-4551-9cf0-689c3378c0c4
Runtime:
	Mono 4.4.0 (mono-4.4.0-branch/f8474c4) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000040

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.2.1 (9548.1)
Build 7C1002

=== Xamarin.iOS ===

Version: 9.4.2.27 (Business Edition)
Hash: 58ba2bc
Branch: master
Build date: 2016-03-03 09:05:19-0500

=== Xamarin.Android ===

Version: 6.0.2.1 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.1.7 (Business Edition)

=== Build Information ===

Release ID: 600004801
Git revision: f73f730c738baf8701a5892b7af64fd468d1dc0c
Build date: 2016-03-14 14:28:06-04
Xamarin addins: 3af7be6c701eb0137645a03e38b82f23b65738c3
Build lane: monodevelop-lion-cycle7

=== Operating System ===

Mac OS X 10.11.3
Darwin Codys-Mac.local 15.3.0 Darwin Kernel Version 15.3.0
	Thu Dec 10 18:40:58 PST 2015
	root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
Comment 1 adrianknight89 2016-12-23 02:45:48 UTC
Not sure if this issue exists in AppCompat.
Comment 2 E.Z. Hart [MSFT] 2017-06-02 18:48:48 UTC
In your repro project, StartPage.cs, comment out line 81 and it'll work as expected.

Here's what's happening: 

You've marked the StackLayout VerticalOptions with EndAndExpand, but you've also set its height to 35. The StackLayout can't actually expand to encompass the Label, so the Label effectively ends up being laid out mostly outside of the StackLayout (it's hanging out of the bottom; to see this better, set the background of the Layout to one color and the background of the Label to another).

On iOS and Android, hit testing starts at the top level of the control hierarchy and works its way down (giving the container controls the option to intercept touches before their children handle them). So the touches on the parts of the Label outside of the StackLayout are in a weird place outside the hierarchy and effectively don't register at all. That's why at the very top of the Label (the part still inside the StackLayout) the tap gesture works. 

Windows doesn't have this issue because it handles touch event processing differently.