var headerView = Ti.UI.createView({
backgroundColor:'#1D561C',
top:0,
height:40
})
var mainWindow = Ti.UI.createWindow({
backgroundColor:'#EAE6DB',
top:0,
x: 40,
height: 'auto',
height:Titanium.Platform.displayCaps.platformHeight,
})
var footerView = Ti.UI.createView({
backgroundColor:'#1D561C',
top:mainWindow.height - 40,
height:40
})
我将页眉定义为40,将页脚定义为40。现在我如何对主窗口说,应该在40 px之后开始...当我在
x:40
中定义页脚时,页脚确实消失了。 最佳答案
这个怎么样?
var mainWindow = Ti.UI.createWindow({
backgroundColor:'#EAE6DB',
top:40,
bottom: 40,
left: 0,
right: 0
});
宽度和高度可以根据您想要与边缘之间的距离来确定-在这种情况下,该高度和高度应与边缘的距离为40。您也可以将相同的逻辑应用于页脚,而不用计算距顶部的距离。
还要注意,如果您希望能够以特定的高度放置元素,可以使用Ti.UI.createScrollView({ layout: 'vertical' }),并让Titanium从顶部偏移它们的偏移量。