根据另一个视图更改窗口大小

时间:2014-02-14 19:35:22

标签: titanium titanium-alloy

我的申请有两种观点。

一个视图固定在50pt高度。

另一个视图必须是100% - 50pt。

我怎样才能在tss中计算?

还是不可能?

如果是这样,我如何决定windowsize?

index.tss

"#tableView": {
    width: "100%" -50,
    height: "98%",
    top:0
}


"#adView": {
    backgroundColor:"black",
    width: "100%",
    height: 50,
    bottom: 0 
}

1 个答案:

答案 0 :(得分:1)

使用Titanium.Platform.DisplayCaps.platformWidth属性来获取窗口的大小,假设#tableview的父级是应用程序窗口:

#tableview : {
    width : Titanium.Platform.DisplayCaps.platformWidth - 50,
   height: "98%",
   top:0
}

选项2是您可以使用postlayout事件在控制器内计算这个:

function adjustTableWidth(e) {
    $.tableView.width = $.tableView.rect.width - 50;
    // Remove the listener so it doesn't keep calling infinitely
    $.tableview.removeEventListener('postlayout, adjustTableWidth);
}
$.tableview.addEventListener('postlayout, adjustTableWidth);

只要确保使用选项2,就可以将TSS设置为:

"#tableView": {
    width: "100%",
    height: "98%",
    top:0
}
相关问题