Bug 60766 - AbsoluteLayout without background captures input on Android
Summary: AbsoluteLayout without background captures input on Android
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: unspecified
Hardware: PC Windows
: --- critical
Target Milestone: ---
Assignee: E.Z. Hart [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-11-20 10:26 UTC by Martin Zikmund
Modified: 2018-02-01 10:49 UTC (History)
5 users (show)

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

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 FIXED

Description Martin Zikmund 2017-11-20 10:26:17 UTC
# Steps to reproduce
1. Create a new Xamarin.Forms solution
2. Change the MainPage.xaml content to:

```
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:ClickThrough"
             x:Class="ClickThrough.MainPage">
    <ContentPage.Content>
        <Grid>
            <Button Text="Click me" Clicked="Button_OnClicked" />
            <AbsoluteLayout />
        </Grid>
    </ContentPage.Content>
</ContentPage>
```
3. Change MainPage.xaml.cs content to:

```
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_OnClicked(object sender, EventArgs e)
        {
            ((Button) sender).Text = "Clicked!";
        }
    }
```

4. Launch the app on Android
5. Try to click the button

# Expected behavior
The button is clicked and its text changes. This behavior works on UWP and iOS.

# Actual behavior
The button cannot be clicked as the `AbsoluteLayout` captures all input.

# Test environment (full version information)
## Xamarin.Forms version

Tested with 2.4.0.280, 2.4.0.91020

## Visual Studio Version Info

Microsoft Visual Studio Enterprise 2017 
Version 15.4.4
VisualStudio.15.Release/15.4.4+27004.2009
Microsoft .NET Framework
Version 4.7.03016

Installed Version: Enterprise

Visual Basic 2017   00369-60000-00001-AA954
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA954
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA954
Microsoft Visual C++ 2017

Visual F# 4.1   00369-60000-00001-AA954
Microsoft Visual F# 4.1

Add New File   3.5
The fastest and easiest way to add new files to any project - including files that start with a dot

ASP.NET and Web Tools 2017   15.0.30925.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.50921.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30915.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Bundler & Minifier   2.5.359
Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

CSS Tools   1.1.21
Provides additional features to the CSS editor in Visual Studio.

EditorConfig Language Service   1.17.226
Language service for .editorconfig files.

EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

File Icons   2.7
Adds icons for files that are not recognized by Solution Explorer

File Nesting   2.6.67
Automatically nest files based on file name and enables developers to nest and unnest any file manually

GitHub.VisualStudio   2.3.4.54
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

HTML Tools   1.0.3
Productivity tools for the HTML editor

Image Optimizer   3.7.117
Uses industry standard tools to optimize any JPEG, PNG and Gifs - including animated Gifs. Can do both lossy and lossless optimization.

Image Sprites   1.4.47
Boost your website's performance by creating image sprites to reduce the amount of HTTP requests needed.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript Transpiler   0.9.24
The simplest way to transpile JS and JSX to EcmaScript 5 without any complicated node.js tools in your project. It uses the TypeScript compiler behind the scenes.

JavaScript UWP Project System   2.0
JavaScript UWP Project System

JetBrains ReSharper Ultimate 2017.3 EAP 4   Build 111.0.20171102.150351-eap04
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2017 JetBrains, Inc.

Markdown Editor   1.11.214
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.2.9000.1
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.2.9000.1
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   1.8
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.2.9000.1
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.7.4-pre (c2d89eb)
Support for debugging Mono processes with Visual Studio.

Multilingual App Toolkit   4.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://aka.ms/matinstall

NuGet Package Manager   4.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Open Command Line   2.1.179
Opens a command line at the root of the project. Support for all consoles such as CMD, PowerShell, Bash etc. Provides syntax highlighting, Intellisense and execution of .cmd and .bat files.

Package Installer   2.0.101
Makes it easier, faster and more convenient than ever to install Bower, npm, Yarn, JSPM, TSD, Typings and NuGet packages to any project

Package Security Alerts   1.0.17
Identifies npm and Bower packages that contains known security vulnerabilities to ensure your project is always using the most secure package versions.

Project File Tools   1.0.1
Provides Intellisense and other tooling for XML based project files such as .csproj and .vbproj files.

SQL Server Data Tools   15.1.61707.200
Microsoft SQL Server Data Tools

Syntax Highlighting Pack   2.7.125
Adds syntax highlighting and snippet support for a wide variety of programming languages such as Clojure, Go, Jade, Lua, Swift, Ruby and many more...

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.3.5.0
TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Unity   3.4.0.2
Visual Studio Tools for Unity

Visual Studio Tools for Universal Windows Apps   15.0.27004.2008
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.IoT   1.0
Package with IoT components for Visual Studio

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Vue.js Pack 2017   1.1.8
Contains HTML Intellisense and code snippets for the Vue.js JavaScript library

Web Accessibility Checker   1.5.56
The easiest way to perform accessibility checks on any ASP.NET web application. Fully customizable and support all the major international accessibility standards.

Web Compiler   1.11.326
Compiler for LESS, Sass and CoffeeScript files

WebJobs Tools v1.0.0   15.0.30915.0
WebJobs Tools v1.0.0

Xamarin   4.7.10.38 (34c1b6c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   8.0.2.1 (HEAD/c2a33d8ea)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.3.0.47 (51128b8)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

ZenCoding   1.2.11
Provides ZenCoding for the HTML Editor - full support for static HTML, Razor and WebForms.
Comment 1 Martin Zikmund 2017-11-20 10:34:50 UTC
A Github repro with the bug https://github.com/MartinZikmund/Xamarin.Forms-Click-Through-Issue
Comment 2 Martin Zikmund 2017-11-20 10:36:30 UTC
I should also note that this worked as expected previously on Android as well, I am not exactly sure which update caused it to not work.
Comment 3 Paul DiPietro [MSFT] 2017-11-20 18:48:14 UTC
I believe that this has to do with some changes which were made to bring the behavior of input into alignment:

https://github.com/xamarin/Xamarin.Forms/pull/935

The behavior as of the latest 2.5.0 stable build is what is expected.
Comment 4 Martin Zikmund 2017-11-21 12:40:52 UTC
But that is a big breaking change, because many apps depend on this behavior.

In my case I had a AbsoluteLayout above map control where I laid out button controls like zoom etc. But now there is no way to do that. I either have to lay out each control separately but then I can't put them in any common container. If I set InputTransparent on the AbsoluteLayout, I can manipulate the map, but can't interact with the buttons inside AbsoluteLayout. 

Is there a good solution to this? The original behavior was consistent with how XAML on WPF and UWP works.
Comment 5 Martin Zikmund 2017-11-21 17:06:00 UTC
I think this is a step back, and a bigger breaking change than is apparent. The new solution goes a bit against intuitive thinking and also mainly against the default behavior in XAML.

In WPF/UWP having an element without a set Background (e.g. Background="{x:Null}") meant the element itself was passing the interaction events to the content behind it, but its children could still be interacted with. When you however set the Background to Transparent, the input events were now handled.

I think it should be done the same way in Xamarin.Forms. When the BackgroundColor is Clear or Default, it should allow "click-through" to elements underneath. When the color is Transparent, it should handle interactions.

I think this is used in many places, but especially with mapping apps, where you have a map control and controls above it. In my case I have to render controls in a Grid above a custom map and also have a layer where I can display "context menus" when user interacts with the map. I need to be able to interact with context menu as well as with the map at the same time.
Comment 6 Martin Zikmund 2017-11-21 17:08:41 UTC
I have asked the question on StackOverflow as well and it contains a concrete example: 

<CustomMapControl />
<Grid x:Name="ControlsGrid">
   <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="*" />
   </Grid.RowDefinitions>
   <Button Grid.Row="1" Text="Zoom in" />
</Grid>
<AboluteLayout x:Name="PlaceMenuContainer" />
Comment 8 E.Z. Hart [MSFT] 2018-01-19 21:21:11 UTC
PR: https://github.com/xamarin/Xamarin.Forms/pull/1621
Comment 9 Rui Marinho 2018-02-01 10:49:53 UTC
Should be fixed on 2.6.0-pre1