diff --git a/apps/tests/ui/style/style-properties-tests.ts b/apps/tests/ui/style/style-properties-tests.ts index 34ed9674e..c59f12f2c 100644 --- a/apps/tests/ui/style/style-properties-tests.ts +++ b/apps/tests/ui/style/style-properties-tests.ts @@ -91,10 +91,13 @@ export function test_setting_minHeight_property_from_CSS_is_applied_to_Style() { } export function test_setting_verticalAlignment_property_from_CSS_is_applied_to_Style() { - test_property_from_CSS_is_applied_to_style("verticalAlignment", "vertical-align", "bottom"); } +export function test_setting_verticalAlignment_middle_is_applied_to_Style() { + test_property_from_CSS_is_applied_to_style("verticalAlignment", "vertical-align", "middle"); +} + export function test_setting_horizontalAlignment_property_from_CSS_is_applied_to_Style() { test_property_from_CSS_is_applied_to_style("horizontalAlignment", "horizontal-align", "right"); } diff --git a/ui/core/view-common.ts b/ui/core/view-common.ts index 42fd3d66d..a88837737 100644 --- a/ui/core/view-common.ts +++ b/ui/core/view-common.ts @@ -717,7 +717,7 @@ export class View extends proxy.ProxyObject implements definition.View { childTop = top + child.marginTop * density; break; - case enums.VerticalAlignment.center: + case enums.VerticalAlignment.center || enums.VerticalAlignment.middle: childTop = top + (bottom - top - childHeight + (child.marginTop - child.marginBottom) * density) / 2; break; diff --git a/ui/enums/enums.d.ts b/ui/enums/enums.d.ts index 00f5466ba..997b6c8b6 100644 --- a/ui/enums/enums.d.ts +++ b/ui/enums/enums.d.ts @@ -161,6 +161,11 @@ */ export var center: string; + /** + * Same as center. An element should be aligned in the middle. + */ + export var middle: string; + /** * An element should be bottom aligned. */ diff --git a/ui/enums/enums.ts b/ui/enums/enums.ts index fc0ba9749..f5b98857a 100644 --- a/ui/enums/enums.ts +++ b/ui/enums/enums.ts @@ -41,6 +41,7 @@ export module HorizontalAlignment { export module VerticalAlignment { export var top = "top"; export var center = "center"; + export var middle = "middle"; export var bottom = "bottom"; export var stretch = "stretch"; } diff --git a/ui/layouts/stack-layout/stack-layout.ios.ts b/ui/layouts/stack-layout/stack-layout.ios.ts index 47d69460a..eecc52257 100644 --- a/ui/layouts/stack-layout/stack-layout.ios.ts +++ b/ui/layouts/stack-layout/stack-layout.ios.ts @@ -114,7 +114,7 @@ export class StackLayout extends common.StackLayout { var childRight = right - left - paddingRight; switch (this.verticalAlignment) { - case enums.VerticalAlignment.center: + case enums.VerticalAlignment.center || enums.VerticalAlignment.middle: childTop = (bottom - top - this._totalLength) / 2 + paddingTop - paddingBottom; break; diff --git a/ui/styling/stylers.android.ts b/ui/styling/stylers.android.ts index c95772608..07a26c4bc 100644 --- a/ui/styling/stylers.android.ts +++ b/ui/styling/stylers.android.ts @@ -175,7 +175,7 @@ export class DefaultStyler implements definition.stylers.Styler { gravity |= android.view.Gravity.TOP; break; - case enums.VerticalAlignment.center: + case enums.VerticalAlignment.center || enums.VerticalAlignment.middle: gravity |= android.view.Gravity.CENTER_VERTICAL; break;