Bug 52635 - AbsoluteLayout doesn't lay out correctly after device rotation
Summary: AbsoluteLayout doesn't lay out correctly after device rotation
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-02-20 19:10 UTC by Sten
Modified: 2017-03-14 18:03 UTC (History)
4 users (show)

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


Attachments
Sample project (54.54 KB, application/zip)
2017-02-20 19:10 UTC, Sten
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 52635 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 Sten 2017-02-20 19:10:28 UTC
Created attachment 19886 [details]
Sample project

AbsoluteLayout as a child to a page gets misplaced upon device rotation if it has Scale!=1.0

Also described in
https://stackoverflow.com/questions/42338841/xamarin-forms-absolutelayout-scalerotation-fail

The page below is incorrectly rendered if the device is rotated. Returning to the original position of the device doesn't restore the original layout

public class AbsoluteRotateFail : ContentPage
{
    // Run this and rotate the device
    public AbsoluteRotateFail()
    {
        Padding = 50; // this is so the page's background is visible
        Scale = 0.60; // this is just to see a larger picture of what's going on
        BackgroundColor = Color.Red;

        var abs = new AbsoluteLayout
        {
            AnchorX = 0,
            AnchorY = 0,
            BackgroundColor = Color.Green,
        };

        var box = new BoxView
        {
            WidthRequest = 100,
            HeightRequest = 100,
            BackgroundColor = Color.Blue,
        };

        AbsoluteLayout.SetLayoutBounds(box, new Rectangle(100, 100, 100, 100));
        abs.Children.Add(box);

        Content = abs;
    }

    protected override void LayoutChildren(double x, double y, double width, double height)
    {
        base.LayoutChildren(x, y, width, height);
        // the animation is just to illustrate, .Scale=1.2 fails the same way 
        Content.ScaleTo(1.2, 3000);
    } 
}
Comment 1 Paul DiPietro [MSFT] 2017-02-22 17:41:35 UTC
Thank you for the reproduction.
Comment 2 Chris King 2017-03-14 18:03:27 UTC
Looks pretty busted on iOS. Will ask Jason to take a look.