Bug 44844 - The RaiseChild() and LowerChild() methods on the Layout class do not correctly change the visual order of native controls
Summary: The RaiseChild() and LowerChild() methods on the Layout class do not correctl...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-09-28 20:02 UTC by Dan Rigby
Modified: 2016-10-13 21:10 UTC (History)
4 users (show)

Tags: Android ac
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 for Bug 44844 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:

Description Dan Rigby 2016-09-28 20:02:47 UTC
Description: The RaiseChild() and LowerChild() methods on the Layout class do not correctly change the visual order of any native controls (either custom renderer or hosted native control) contained within the supplied view on Android.

Expected Behavior: Visual order of native controls should change as a result of these methods calls just as the built in Xamarin.Forms controls do.

Customer has indicated that this behavior is present on versions of Xamarin.Forms ranging from through and on Android 4.4.2, 5.0, and 5.1. Newer versions of Xamarin.Forms and Android have not been tested.

Customer has created a sample repository demonstrating the behavior on GitHub:
Comment 1 adrianknight89 2016-10-11 01:48:04 UTC
I don't think the video was provided in that project? I'm getting can't play error.
Comment 2 Dan Rigby 2016-10-13 21:10:01 UTC
Notes from a call with Jason:

In Android, there are two widget orderings: drawing order & layout order.
When Xamarin.Forms rearranges widgets with LowerChild() or RaiseChild(), rather than pulling elements from hierarchy/putting in new location, which triggers relayout/other expensive operations, it just updates the z-index and triggers a redraw.

This doesn't work with hardware accelerated controls such as a video player.
For controls like this, you actually have to remove/re-add the child in order to change the layout order.

Layout order is order that views are added to the screen; Ex. getChildAt(0) gets the first child in layout order.
Add/remove child is the only way to change the layout order.