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


TypeScript GridLayout.setColumn方法代码示例

本文整理汇总了TypeScript中tns-core-modules/ui/layouts/grid-layout.GridLayout.setColumn方法的典型用法代码示例。如果您正苦于以下问题:TypeScript GridLayout.setColumn方法的具体用法?TypeScript GridLayout.setColumn怎么用?TypeScript GridLayout.setColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tns-core-modules/ui/layouts/grid-layout.GridLayout的用法示例。


在下文中一共展示了GridLayout.setColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createPage

export function createPage() {
    var page = new pages.Page();
    var gridLayout = new gridLayoutModule.GridLayout();

    var lengths = [
        new gridLayoutModule.ItemSpec(140, "pixel"),
        new gridLayoutModule.ItemSpec(1, "star"),
        new gridLayoutModule.ItemSpec(140, "pixel")
    ];

    var rows = 2;
    var cols = 3;
    var row;
    var col;

    for (row = 0; row < rows; row++) {
        var rowDef = new gridLayoutModule.ItemSpec(1, "auto");
        gridLayout.addRow(rowDef);
    }

    for (col = 0; col < cols; col++) {
        gridLayout.addColumn(lengths[col]);
    }

    var btn = new btns.Button();
    btn.text = "Col: 0";
    gridLayoutModule.GridLayout.setColumn(btn, 0);
    gridLayoutModule.GridLayout.setRow(btn, 0);
    gridLayout.addChild(btn);

    var btn2 = new btns.Button();
    btn2.text = "Col: 2";
    gridLayoutModule.GridLayout.setColumn(btn2, 2);
    gridLayoutModule.GridLayout.setRow(btn2, 0);
    gridLayout.addChild(btn2);

    var txt = new tb.TextField();
    txt.text = "Col: 1";
    txt.width = 140;
    gridLayoutModule.GridLayout.setColumn(txt, 1);
    gridLayoutModule.GridLayout.setRow(txt, 0);
    gridLayout.addChild(txt);

    var txt2 = new tb.TextField();
    txt2.text = "Col: All";
    gridLayoutModule.GridLayout.setColumnSpan(txt2, 3);
    gridLayoutModule.GridLayout.setRow(txt2, 1);
    gridLayout.addChild(txt2);

    page.content = gridLayout;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:52,代码来源:page12.ts

示例2: createPage

export function createPage() {
    var StackLayout = require("ui/layouts/stack-layout").StackLayout;
    var Label = require("ui/label").Label;
    var Image = require("ui/image").Image;

    var stack = new StackLayout();
    var grid = new gridModule.GridLayout();
    stack.addChild(grid);

    grid.addColumn(new gridModule.ItemSpec(80, "pixel"));
    grid.addColumn(new gridModule.ItemSpec(1, "star"));
    grid.addRow(new gridModule.ItemSpec(1, "auto"));
    grid.addRow(new gridModule.ItemSpec(1, "auto"));

    var defaultImageSource = imageSource.fromFile(__dirname + "/test.png");

    var img = new Image();
    img.source = defaultImageSource;

    img.width = 80;
    img.height = 80;
    img.verticalAlignment = enums.VerticalAlignment.bottom;
    gridModule.GridLayout.setRowSpan(img, 2);
    grid.addChild(img);

    var titleLabel = new Label();
    titleLabel.textWrap = true;
    titleLabel.text = "some text goes here";
    gridModule.GridLayout.setColumn(titleLabel, 1);
    grid.addChild(titleLabel);

    var commentsLabel = new Label();
    commentsLabel.text = "comments";
    commentsLabel.verticalAlignment = enums.VerticalAlignment.bottom;
    gridModule.GridLayout.setRow(commentsLabel, 1);
    gridModule.GridLayout.setColumn(commentsLabel, 1);
    grid.addChild(commentsLabel);

    var page = new pages.Page();
    page.content = stack;
    page.css = "GridLayout { background-color: yellow } image { background-color: green } label { background-color: red } stackpnael { background-color: pink }";
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:43,代码来源:page10.ts

示例3: createPage

export function createPage() {
    var StackLayout = new sp.StackLayout();
    var grid = new gridModule.GridLayout();
    grid.horizontalAlignment = "left";

    StackLayout.addChild(grid);

    var btn1 = new button.Button();
    btn1.text = "btn1";
    var btn2 = new button.Button();
    btn2.text = "btn2";
    var btn3 = new button.Button();
    btn3.text = "btn3";
    var btn4 = new button.Button();
    btn4.text = "btn4";

    grid.addChild(btn2);
    grid.addChild(btn3);
    grid.addChild(btn4);

    var sp1 = new sp.StackLayout();
    sp1.orientation = "horizontal";
    sp1.height = 200;

    var b1 = new button.Button();
    b1.text = "nested Btn1";
    sp1.addChild(b1);

    var b2 = new button.Button();
    b2.text = "nested Btn2";
    sp1.addChild(b2);

    grid.addChild(sp1);

    gridModule.GridLayout.setColumn(btn4, 1);
    gridModule.GridLayout.setColumn(btn3, 1);
    gridModule.GridLayout.setRow(btn2, 1);
    gridModule.GridLayout.setRow(btn4, 1);

    grid.addRow(new gridModule.ItemSpec());
    grid.addRow(new gridModule.ItemSpec());
    grid.addColumn(new gridModule.ItemSpec());
    grid.addColumn(new gridModule.ItemSpec());

    var page = new Page();
    //page.content = GridLayout;
    page.content = StackLayout;
    var x = 1;
    btn1.on(button.Button.tapEvent, function () {
        x++;
        var gravity;
        //btn1.android.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT));
        if (x === 1) {
            gravity = android.view.Gravity.CENTER;
        }
        else if (x === 2) {
            gravity = android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM;
        }
        else {
            gravity = android.view.Gravity.LEFT | android.view.Gravity.TOP;
            x = 0;
        }

        for (var i = 0; i < grid.getChildrenCount(); i++) {
            grid.getChildAt(i).android.setGravity(gravity);
        }
    });
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:69,代码来源:page11.ts


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