Bug 59086 - 2.4.0 breaks layout on Android
Summary: 2.4.0 breaks layout on Android
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-29 04:12 UTC by Kent
Modified: 2017-11-27 01:49 UTC (History)
3 users (show)

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


Attachments
Repro (71.67 KB, application/x-zip-compressed)
2017-08-29 04:12 UTC, Kent
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 Kent 2017-08-29 04:12:31 UTC
Created attachment 24449 [details]
Repro

In upgrading from 2.3.4.247 to 2.4.0-266-pre1, I noticed that my entire UI was shifted down by the height of the status bar. The bottom of my UI was therefore cut off, and my master detail no longer popped up over the status bar like it used to.

I put together a standalone repro with a simple MasterDetailPage and, sure enough, upgrading that exhibited the exact same behavior. The repro is attached.
Comment 1 Jimmy [MSFT] 2017-09-01 21:15:18 UTC
I modified the attached project to have a Label at the top and bottom of the Detail and Master page and I did not experience the bottom of the UI being cut off. However I did notice the behavior change with the Master page no longer running underneath the status bar area.

This is the same default behavior as in a native Android app so we are now just aligning with it. In order to make the status bar translucent again, in your Android theme add:

> <item name="android:windowTranslucentStatus">true</item>

and that will also restore the previous behavior. Do note however that there is now an issue when having a translucent status bar where the page content gets covered by it. That issue is being tracked with bug 59185.
Comment 2 Kent 2017-11-24 00:43:18 UTC
The reason my UI was cut off at the bottom was due to the use of the KeyboardOverlapAssistant detailed on Adam Pedley's blog here: https://xamarinhelp.com/accommodate-on-screen-keyboard-xamarin-forms/

It doesn't take into account the lesser space now afforded the UI in 2.4. Also, it's worth noting that simply adding the windowTranslucentStatus setting is not sufficient. Doing so shifts the entire UI up such that any icons in the toolbar are now parially overlapping icons in the status bar.

Still trying to figure out a way to resolve all this mess...
Comment 3 Kent 2017-11-24 01:01:28 UTC
For those following in my footsteps...

The code for the KeyboardOverlapAssistant included this method:

private int ComputeUsableHeight()
{
    var r = new Rect();
    this.mChildOfContent.GetWindowVisibleDisplayFrame(r);

    if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
    {
        return r.Bottom - r.Top;
    }

    return r.Bottom;
}

The calculation is now incorrect for XF 2.4 and can be changed to:

private int ComputeUsableHeight()
{
    var r = new Rect();
    this.mChildOfContent.GetWindowVisibleDisplayFrame(r);
    return r.Bottom - r.Top;
}

This seems to work fine for me, but I haven't done a lot of testing yet.
Comment 4 Kent 2017-11-24 01:13:20 UTC
An alternative implementation that also seems to work fine:

        private int ComputeUsableHeight()
        {
            var r = new Rect();
            this.mChildOfContent.GetDrawingRect(r);
            return r.Height();
        }
Comment 5 Kent 2017-11-27 01:49:30 UTC
I take back that last comment - it seems to work for Entry but not for Editor, so I'm sticking with the GetWindowVisibleDisplayFrame call.