Set view to phone width and height
I've made a simple view. Its just a box. Can I set the width and height to the phones width and height? I tried 'auto' but if I do that nothing shows up.
7 Answers
-
I don't know why I didn't mention this before but you can pin the view by setting all 4 sides to 0.
var view = Ti.UI.createView({backgroundColor: '#f00', left: 0, top: 0, right: 0, bottom: 0});
-
Do you have a root window and the view added to it?
-
Have you tried height: '100%', width: '100%'
-
width:Ti.Platform.displayCaps.platformWidth, height:Ti.Platform.displayCaps.platformHeight
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Platform.DisplayCaps-object.html
-
Fred,
Unless I am mistaken this would work well provided the device started and remained in a specific orientation. If the device orientation changes, you'd need to hook the orientationchange event and change the height and width to match the new orientation.
-
yeah I first have my app.js file.
Then from that I added my login.js file and I am in that window.
Inside login.js, I did:
var win = Titanium.UI.currentWindow;//made myView
win.add(myView);
-
100% did the trick