当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript View.layoutChild方法代码示例

本文整理汇总了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);
        });
开发者ID:329379172,项目名称:NativeScript,代码行数:48,代码来源:dock-layout.ios.ts

示例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);
        });
开发者ID:329379172,项目名称:NativeScript,代码行数:13,代码来源:absolute-layout.ios.ts


注:本文中的ui/core/view.View.layoutChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。