Bug 58975 - Gradient background color issue when devices orientation change Landscape to Portrait Mode for both IOS and Android
Summary: Gradient background color issue when devices orientation change Landscape to ...
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-08-23 13:58 UTC by Ojas Teredesai
Modified: 2017-08-24 12:11 UTC (History)
3 users (show)

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

sample project for reproducing the issue. (57.64 KB, application/x-zip-compressed)
2017-08-23 13:58 UTC, Ojas Teredesai

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:

Description Ojas Teredesai 2017-08-23 13:58:05 UTC
Created attachment 24373 [details]
sample project for reproducing the issue.

We have tried with Stack Layout as well as Grid Layout by including one label in to it and we are setting Stack Layout background color as gradient color with the help  of randerer. So problem occurs when we rotate device orientation from landscape to portrait and vice versa then its width does not cover full screen it becomes half. We have attached the code for the iOS renderer for your reference.
Comment 1 Jimmy [MSFT] 2017-08-23 20:51:22 UTC
I ran the attached project on both Android and iOS and I only experienced the issue on iOS. 

This is happening because Draw() only gets called when the item first appears and not when the screen is rotated. Instead you should add the gradient layer in LayoutSubviews() as this does get called when the screen orientation changes, and set the layer's Frame to this.Frame. 

Hope this helps! If you are also seeing this on Android, please re-open this report and let us know what device/emulator you are testing on and what version of Android it is running. Thanks!
Comment 2 Pragnesh 2017-08-24 12:11:53 UTC
Hi Jimmy 

LayoutSubviews() working in IOS.
your solution Work.