2016-05-23 43 views
0

我有一个布局,它有肖像时的总和规格。但是当我改变屏幕方向时,布局需要重新整理以适应整个屏幕。问题是布局保持他的尺寸。所以如果布局开始纵向,我改变为横向布局保持纵向配置。我怎样才能让自己的布局自动重组屏幕方向的变化?重新组织钛定向变化的布局

如何创建自己的看法:

var deviceHeight = Ti.Platform.displayCaps.platformHeight, 
    deviceWidth = Ti.Platform.displayCaps.platformWidth, 
    platform = Ti.Platform.osname; 

    if (platform == 'android') { 
     deviceHeight = Math.round(Ti.Platform.displayCaps.platformHeight/Ti.Platform.displayCaps.logicalDensityFactor); 
     deviceWidth = Math.round(Ti.Platform.displayCaps.platformWidth/Ti.Platform.displayCaps.logicalDensityFactor); 
    } 

var View = Ti.UI.createView({ 
    height : deviceHeight, 
    width : deviceWidth, 
    backgroundColor : 'white', 
    layout : 'vertical' 
}); 

回答

2

非常重要:不要指定点/像素宽度,但以百分比。或者使用相对宽度。例如,如果你想有一个观点,即是全宽,零下10左,右10,指定:作为网站的不同

Ti.UI.createView(){ 
    left: 10, 
    right: 10 
} 

款待应用!使一切相对。有很多决议是不可能做出布局PER分辨率的。为移动设备制作单一解决方案,并可能为平板电脑重新安排一些内容。

如果你真的想手动重绘,使用此事件后再次重新定义你所有的观点:

Ti.Gesture.addEventListener('orientationchange',function(e) { 
}); 

对于这个工作,你需要保持所有的意见参考,并调整你喜欢的地方。

+0

请海我编辑的帖子 –

+0

你真的不想自定义做与设备的宽度和高度。然后你将不得不手动重绘每一个元素。看我的编辑 –