• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript grid-layout.GridLayout类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createPage

export function createPage() {
    var page = new pages.Page();
    var grid = new gridModule.GridLayout();

    var btn = new buttons.Button();
    btn.text = "print";
    btn.on("tap", (d) => {
        print();
    });

    grid.addChild(btn);

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


示例2: navigatingTo

export function navigatingTo(args) {
    const grid: GridLayout = args.object.getViewById("root");
    for (let x = 0; x < 12; x++) {
        for (let y = 0; y < 16; y++) {
            const image = new Image();

            const img = sources[x % 4];
            const src = imageSource.fromFileOrResource(img.src);
            src.rotationAngle = img.rotation;
            image.src = src;

            image.stretch = stretchModes[y % 4];
            image.row = y;
            image.col = x;

            grid.addChild(image);

            switch (Math.floor(x / 4)) {
                case 1:
                    image.borderWidth = "3";
                    break;
                case 2:
                    image.borderWidth = "3";
                    image.borderColor = "blue";
                    break;
            }

            switch (Math.floor(y / 4)) {
                case 1:
                    image.borderRadius = "12";
                    break;
                case 2:
                    image.borderRadius = "6 18 6 18";
                    break;
                case 3:
                    image.borderWidth = "0 2 4 6";
                    image.borderRadius = "6 18 6 18";
                    break;
            }

            image.backgroundColor = new Color(0x6600FFFF);
        }
    }
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:44,代码来源:mode-matrix.ts


示例3: content

    set content(value: View) {
        if (this._content) {
            this._content.parentNode = undefined;
        }

        this._content = value;

        if (value) {
            this._content.parentNode = this;
        }

        this.ngAppRoot = value;

        if (this._content instanceof ProxyViewContainer) {
            const grid = new GridLayout();
            grid.addChild(this._content);
            this.ngAppRoot = grid;
        }
    }
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:19,代码来源:app-host-view.ts


示例4: createPage

export function createPage() {
    var grid = new gridModule.GridLayout();

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

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

    var image = new img.Image();
    image.stretch = "fill";
    image.verticalAlignment = "bottom";
    image.horizontalAlignment = "center";

    image.imageSource = imageSource.fromFile(__dirname + "/test.png");
    grid.addChild(image);

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


示例5: createPage

export function createPage() {
    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.src = 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:m-abs,项目名称:NativeScript,代码行数:39,代码来源:page10.ts


示例6: 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


示例7: createPage

export function createPage() {
    var page = new pages.Page();
    var grid = new gridModule.GridLayout();
    grid.addRow(new gridModule.ItemSpec());
    grid.addRow(new gridModule.ItemSpec());
    page.content = grid;

    var count = 0;
    var control = new btns.Button();
    control.text = "test control";
    control.on(btns.Button.tapEvent, (data) => { control.text = "count: " + count++; });
    grid.addChild(control);

    var scrollView = new scroll.ScrollView();
    gridModule.GridLayout.setRow(scrollView, 1);
    grid.addChild(scrollView);
    var stack = new stacks.StackLayout();
    scrollView.content = stack;

    function createNumericPropertyUI(desc: NumericProeprtyDescriptor) {
        var lbl = new labels.Label();
        lbl.text = desc.name;
        lbl.horizontalAlignment = "left";
        stack.addChild(lbl);

        var slider = new sliders.Slider();
        slider.minValue = desc.min;
        slider.maxValue = desc.max;
        slider.value = desc.value;
        stack.addChild(slider);

        var options: bindable.BindingOptions = {
            sourceProperty: "value",
            targetProperty: desc.name,
        };
        control.bind(options, slider);
    };

    function createBooleanPropertyUI(desc: BoolPropertyDescriptor) {
        var lbl = new labels.Label();
        lbl.text = desc.name;
        lbl.horizontalAlignment = "left";
        stack.addChild(lbl);

        var sw = new switches.Switch();
        sw.checked = desc.value;
        sw.horizontalAlignment = "left";
        stack.addChild(sw);

        var options: bindable.BindingOptions = {
            sourceProperty: "checked",
            targetProperty: desc.name,
        };
        control.bind(options, sw);
    };

    function createStringPropertyUI(desc: StringPropertyDescriptor) {
        var lbl = new labels.Label();
        lbl.text = desc.name;
        lbl.horizontalAlignment = "left";
        stack.addChild(lbl);

        var txt = new textView.TextView();
        txt.text = desc.value;
        stack.addChild(txt);

        var options: bindable.BindingOptions = {
            sourceProperty: "text",
            targetProperty: desc.name,
        };
        control.bind(options, txt);
    };

    createNumericPropertyUI({ name: "style.minWidth", value: 30, min: 10, max: 300 });
    createNumericPropertyUI({ name: "style.width", value: 100, min: 10, max: 300 });

    createNumericPropertyUI({ name: "style.minHeight", value: 30, min: 10, max: 300 });
    createNumericPropertyUI({ name: "style.height", value: 100, min: 10, max: 300 });

    createBooleanPropertyUI({ name: "isEnabled", value: true });
    createNumericPropertyUI({ name: "style.opacity", value: 1, min: 0, max: 1 });
    createStringPropertyUI({ name: "style.visibility", value: "visible" });

    createStringPropertyUI({ name: "style.horizontalAlignment", value: "stretch" });
    createStringPropertyUI({ name: "style.verticalAlignment", value: "stretch" });
    createStringPropertyUI({ name: "margin", value: "20" });

    createStringPropertyUI({ name: "className", value: "testClass" });

    page.css = ".testClass { background-color: LightGreen }";
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:92,代码来源:property-bindings.ts


示例8: 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类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript stack-layout.StackLayout类代码示例发布时间:2022-05-25
下一篇:
TypeScript label.Label类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap