如何在Titanium中显示我的标题和底部?

时间:2015-02-22 01:44:09

标签: titanium

var galWin = Ti.UI.createWindow({

    title: "Alejandro's Big Adventure",
    modal: true,
    backgroundColor: "828F99",
    layout: "horizontal"

});


var border = Ti.UI.createView({

    backgroundColor: "2585CC",
    height: 1,
    width: pWidth,
    top: 30

});


var bottomButton = Ti.UI.createView({

    backgroundColor: "828F99",
    height: "10%",
    width: pWidth,
    bottom: 0

});


var galContainer = Ti.UI.createScrollView({

    top: 0,
    width: pWidth,
    height: pHeight - border.height - border.top,
    backgroundColor: "2585CC",
    layout: "horizontal",
    contentWidth: pWidth,
    showVerticalScrollIndicator: true

});

for(var i = 0; i < myImages.length; i++){

    var view = Ti.UI.createView({

        borderRadius: 10,
        top: margin,
        left: margin,
        width: size,
        height: size

    });

    var img = Ti.UI.createImageView({

        image: "images/" + myImages[i],
        top: 0,
        width: view.width * 1.25,
        height: view.height * 2

    });

    view.add(img);
    galContainer.add(view);

};

1 个答案:

答案 0 :(得分:0)

首先:如果你想得到窗口的标题,那就是标题 所以你可以使用像这样的getTitle()方法获得它

galWin.getTitle()

其次:对于底部
如果你想在这里得到窗口的底部你不能这样做,因为窗口是你层次结构中的顶级元素,是文档

Window's bottom position, in platform-specific units.
On Android, this property only works with lightweight windows. See "Android Heavyweight and Lightweight Windows" in the main description of Titanium.UI.Window for more information.

所以你根据它的父元素得到元素的底部,所以这里窗口没有父元素

但一般来说,如果你想获得任何元素的底部

您可以使用getBottom()但请注意,只有在元素内部提供了一个底部属性而不是您将获得Nan

时,此方法才会返回一个数字

如果你想在屏幕上绘制布局后获得元素的底部,你可以postlayout事件并使用rect.y获取元素的顶部然后你可以添加元素高度最后从窗口高度减去它,如果你没有窗口高度,你可以使用displayCaps.contentHeight来获得屏幕高度

对不起,希望对此有所帮助

相关问题