mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
vertical-alignment middle support added
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
5
ui/enums/enums.d.ts
vendored
5
ui/enums/enums.d.ts
vendored
@ -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.
|
||||
*/
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user