2014-02-14 53 views
1

我的应用程序有两个视图。根据另一个视图更改窗口大小

一个视图固定为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

使用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); 

只要确保您使用选项二,您将TSS设置为:

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