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() {
|
export function test_setting_verticalAlignment_property_from_CSS_is_applied_to_Style() {
|
||||||
|
|
||||||
test_property_from_CSS_is_applied_to_style("verticalAlignment", "vertical-align", "bottom");
|
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() {
|
export function test_setting_horizontalAlignment_property_from_CSS_is_applied_to_Style() {
|
||||||
test_property_from_CSS_is_applied_to_style("horizontalAlignment", "horizontal-align", "right");
|
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;
|
childTop = top + child.marginTop * density;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case enums.VerticalAlignment.center:
|
case enums.VerticalAlignment.center || enums.VerticalAlignment.middle:
|
||||||
childTop = top + (bottom - top - childHeight + (child.marginTop - child.marginBottom) * density) / 2;
|
childTop = top + (bottom - top - childHeight + (child.marginTop - child.marginBottom) * density) / 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
5
ui/enums/enums.d.ts
vendored
5
ui/enums/enums.d.ts
vendored
@ -161,6 +161,11 @@
|
|||||||
*/
|
*/
|
||||||
export var center: string;
|
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.
|
* An element should be bottom aligned.
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +41,7 @@ export module HorizontalAlignment {
|
|||||||
export module VerticalAlignment {
|
export module VerticalAlignment {
|
||||||
export var top = "top";
|
export var top = "top";
|
||||||
export var center = "center";
|
export var center = "center";
|
||||||
|
export var middle = "middle";
|
||||||
export var bottom = "bottom";
|
export var bottom = "bottom";
|
||||||
export var stretch = "stretch";
|
export var stretch = "stretch";
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ export class StackLayout extends common.StackLayout {
|
|||||||
var childRight = right - left - paddingRight;
|
var childRight = right - left - paddingRight;
|
||||||
|
|
||||||
switch (this.verticalAlignment) {
|
switch (this.verticalAlignment) {
|
||||||
case enums.VerticalAlignment.center:
|
case enums.VerticalAlignment.center || enums.VerticalAlignment.middle:
|
||||||
childTop = (bottom - top - this._totalLength) / 2 + paddingTop - paddingBottom;
|
childTop = (bottom - top - this._totalLength) / 2 + paddingTop - paddingBottom;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ export class DefaultStyler implements definition.stylers.Styler {
|
|||||||
gravity |= android.view.Gravity.TOP;
|
gravity |= android.view.Gravity.TOP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case enums.VerticalAlignment.center:
|
case enums.VerticalAlignment.center || enums.VerticalAlignment.middle:
|
||||||
gravity |= android.view.Gravity.CENTER_VERTICAL;
|
gravity |= android.view.Gravity.CENTER_VERTICAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user