Bug 43186 - AbsoluteLayout rotation misplaces layout
Summary: AbsoluteLayout rotation misplaces layout
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.1
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-08-08 22:26 UTC by Rafal Grzybowski
Modified: 2017-02-20 19:11 UTC (History)
4 users (show)

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


Attachments
Solution to reproduce the problem + screenshots. (279.35 KB, application/zip)
2016-08-08 22:26 UTC, Rafal Grzybowski
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 for Bug 43186 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Rafal Grzybowski 2016-08-08 22:26:04 UTC
Created attachment 16950 [details]
Solution to reproduce the problem + screenshots.

I have a very simple layout:

    <?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:MenuLayoutTest" x:Class="MenuLayoutTest.MenuLayoutTestPage">
	    <ContentView>
		    <StackLayout Orientation="Vertical" Spacing="0">
			    <ContentView x:Name="AppPageTopBar" HeightRequest="70" BackgroundColor="Yellow" />
			    <AbsoluteLayout VerticalOptions="FillAndExpand">
				    <ContentView x:Name="AppPageModuleContent" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Gray"/>
    				<ContentView x:Name="AppPageSideMenu" AbsoluteLayout.LayoutBounds="0,0,244,1" AbsoluteLayout.LayoutFlags="HeightProportional" BackgroundColor="Fuchsia" IsVisible="False"  Padding="12">
					    <ContentView BackgroundColor="Green"/>
				    </ContentView>
			    </AbsoluteLayout>
		    </StackLayout>
	    </ContentView>
    </ContentPage>

with the following code behind that simply toggles the visibility of the fuchsia / green area: 

	public partial class MenuLayoutTestPage : ContentPage
	{
		public MenuLayoutTestPage()
		{
			InitializeComponent();

			ICommand command = new MyCommand(AppPageSideMenu);

			AppPageTopBar.GestureRecognizers.Add(
				new TapGestureRecognizer
				{
					Command = command
			});
		}

		public class MyCommand : ICommand
		{
			private readonly View view;

			public MyCommand(View view)
			{
				this.view = view;
			}

			public event EventHandler CanExecuteChanged;

			public bool CanExecute(object parameter)
			{
				return true;
			}

			public void Execute(object parameter)
			{
				view.IsVisible = !view.IsVisible;
			}
		}
	}


If we open the app in portrait mode and tap the yellow area we will see a green box with fuchsia border displayed to the left (see fine.png from the attachment).

But after a few rotations and show / hide options the layout goes wrong, leaving a lot of space below (see wrong.png).

I have managed to reproduce it 100% on iOS Simulator, iPad and Nexus 9 with the following steps:

 - kill the app and restart in portrait mode
 - rotate left twice
 - tap the yellow area to show fuchsia / green area
 - tap again to hide it
 - rotate left twice
 - tap the yellow area to show fuchsia / green area
 - tap again to hide it
 - rotate right **once**
 - tap the yellow area to show fuchsia / green area
 - tap again to hide it
 - rotate right **once**
 - tap the yellow area to show fuchsia / green area
 - you should have seen the broken layout