Bug 31684 - Vertical centering of the Xamaring.Forms.Switch does not work for iOS but it does for Android.
Summary: Vertical centering of the Xamaring.Forms.Switch does not work for iOS but it ...
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-06 20:48 UTC by Andy
Modified: 2016-04-11 03:19 UTC (History)
4 users (show)

Tags:
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 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 INVALID

Description Andy 2015-07-06 20:48:45 UTC
When I try to center a switch in Xamarin forms, it does not center vertically on iOS. The same switch code on Android seems very well centered.
Comment 1 Andy 2015-07-06 20:50:47 UTC
I should have mentioned that this is in a StackLayout

			mSwitch = new Xamarin.Forms.Switch {
				HorizontalOptions = LayoutOptions.EndAndExpand,
				VerticalOptions = LayoutOptions.CenterAndExpand,
			};
Comment 2 Arpit Jha 2015-07-07 05:42:41 UTC
I have checked this issue with Xamarin.Forms version 1.4.3.6374 and I am observing that when I modified your code as  

using System;

using Xamarin.Forms;

namespace AppForms
{
	public class App : Application
	{
		public App ()
		{
			// The root page of your application
			MainPage = new ContentPage {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new Label {
							XAlign = TextAlignment.Center,
							Text = "Welcome to Xamarin Forms!"
						},

					new Xamarin.Forms.Switch {
							HorizontalOptions = LayoutOptions.CenterAndExpand,
							VerticalOptions = LayoutOptions.CenterAndExpand,
						}
					}
				}
			};
		}

		
	}
}
and Now I am getting switch control in center for both and iOS 

Please let me know if you are facing this issue again?

Environment Info:=== Xamarin Studio ===

Version 5.9.5 (build 3)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
	Mono 4.0.2 ((detached/7c46795)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020015

=== Xamarin.Android ===

Version: 5.1.4.21 (Trial Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.10.4.3 (Trial Edition)
Hash: e4cb14c
Branch: master
Build date: 2015-07-03 04:03:14-0400

=== Xamarin.Mac ===

Version: 2.1.0.1195 (Starter Edition)

=== Build Information ===

Release ID: 509050003
Git revision: 5716b0c7ef341fff65ce7bd750be2b9ae64a1807
Build date: 2015-06-30 15:34:42-04
Xamarin addins: 8adf470161f63b54bcfea78416e4541f6d55d7bb

=== Operating System ===

Mac OS X 10.10.4
Darwin mac360-xamarins-Mac-mini.local 14.4.0 Darwin Kernel Version 14.4.0
    Thu May 28 11:35:04 PDT 2015
    root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
Comment 3 Arpit Jha 2015-07-07 05:46:24 UTC
Please provide us sample project and Xamarin.Forms version if you are facing this issue again, So that we can reproduce this issue at our end.
Comment 4 Arpit Jha 2015-07-07 05:49:04 UTC
An update to comment 2 
Screencast : http://www.screencast.com/t/rgLuWlHXtUmK
Comment 5 Andy 2015-07-10 12:50:42 UTC
This was caused by a different issue it seems. I had the padding set for the parent stack layout to 15.0 for vertical. In that instance, instead of centering and clipping the object, the top-most vertical padding is applied  more than the bottom-most vertical padding. Thank you for looking into this so thoroughly

I've modified it to have that padding applied to the right side instead.

Padding = new Thickness(10.0, 0.0, 15.0, 0.0);

I believe that a warning should be logged if the padding causes an object's bounds to extend out of it's parent.

The original code was 

Padding = new Thickness(10.0, 15.0);
Comment 6 Jason Smith [MSFT] 2016-04-11 03:19:25 UTC
Described behavior is expected.