How to set Landscape mode
I would like to make landscape mode app. Please advise me how to set it.
6 Answers
-
You can instruct Titanium which orientation modes you app supports by setting the
orientationModes
property of your window.win.orientationModes = [ Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT, Titanium.UI.FACE_UP, Titanium.UI.FACE_DOWN ];
This should be an array of the modes you support for the device. This affects which modes your app can rotate to when the user rotates the device.
To programmatically change the orientation, you can do something like this:
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;
Note that this software rotates the main UI of the device to that rotation.
-
Thank you for the advise!
I set
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;
in app.js as bellow.But the splash screen is not landscape mode and also view in window is miss alignment.
Do I need to set the view position?
If you have any example document, please advise me.
Titanium.UI.setBackgroundColor('#000');
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;var win1 = Titanium.UI.createWindow({
backgroundColor:'#fff'
});var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'}
});win1.orientationModes = [
Titanium.UI.LANDSCAPE_LEFT
];win1.add(label1);
win1.open(); -
Thank you for the advise!
I set
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;
in app.js as bellow.But the splash screen is not landscape mode and also view in window is miss alignment.
Do I need to set the view position?
If you have any example document, please advise me.
Titanium.UI.setBackgroundColor('#000');
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;var win1 = Titanium.UI.createWindow({
backgroundColor:'#fff'
});var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'}
});win1.orientationModes = [
Titanium.UI.LANDSCAPE_LEFT
];win1.add(label1);
win1.open(); -
Thank you, Matthew!
Your idea is good. But as you know, I want to have landscape oriented app like game apps.
I hope some way to make it happen. -
http://developer.appcelerator.com/question/125945/force-single-orientation-only
-
I too am having trouble with this. I am trying to create a landscape oriented program. I can get the display and windows to rotate, but every window still seems by default to have the same dimensions as when it was vertical. The fullscreen boolean still seems to assume that the window is in portrait orientation. The only way I can get the window to fill the frame properly is to manually add the dimensions, then reset the top and left dimensions to 0,0. Is there a more generic way to do this that will fit more devices with different resolutions?
var win = Titanium.UI.createWindow({
title:'testWin',
backgroundColor:'#ff0',
orientationModes:[Titanium.UI.LANDSCAPE_RIGHT],
//fullscreen:true
width:480,
height:360,
left:0,
top:0
});