本文整理匯總了TypeScript中ui/core/view.View.layoutChild方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript View.layoutChild方法的具體用法?TypeScript View.layoutChild怎麽用?TypeScript View.layoutChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ui/core/view.View
的用法示例。
在下文中一共展示了View.layoutChild方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: switch
this.eachLayoutChild((child, last) => {
let lp: CommonLayoutParams = child.style._getValue(nativeLayoutParamsProperty);
let childWidth = child.getMeasuredWidth() + (lp.leftMargin + lp.rightMargin) * density;
let childHeight = child.getMeasuredHeight() + (lp.topMargin + lp.bottomMargin) * density;
if (last && this.stretchLastChild) {
// Last child with stretch - give it all the space and return;
View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight);
return;
}
let dock = DockLayout.getDock(child);
switch (dock) {
case Dock.top:
childLeft = x;
childTop = y;
childWidth = remainingWidth;
y += childHeight;
remainingHeight = Math.max(0, remainingHeight - childHeight);
break;
case Dock.bottom:
childLeft = x;
childTop = y + remainingHeight - childHeight;
childWidth = remainingWidth;
remainingHeight = Math.max(0, remainingHeight - childHeight);
break;
case Dock.right:
childLeft = x + remainingWidth - childWidth;
childTop = y;
childHeight = remainingHeight;
remainingWidth = Math.max(0, remainingWidth - childWidth);
break;
case Dock.left:
default:
childLeft = x;
childTop = y;
childHeight = remainingHeight;
x += childWidth;
remainingWidth = Math.max(0, remainingWidth - childWidth);
break;
}
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight);
});
示例2:
this.eachLayoutChild((child, last) => {
let lp: CommonLayoutParams = child.style._getValue(nativeLayoutParamsProperty);
let childWidth = child.getMeasuredWidth();
let childHeight = child.getMeasuredHeight();
let childLeft = (this.paddingLeft + AbsoluteLayout.getLeft(child)) * density;
let childTop = (this.paddingTop + AbsoluteLayout.getTop(child)) * density;
let childRight = childLeft + childWidth + (lp.leftMargin + lp.rightMargin) * density;
let childBottom = childTop + childHeight + (lp.topMargin + lp.bottomMargin) * density;
View.layoutChild(this, child, childLeft, childTop, childRight, childBottom);
});