I have three view's, a main view and two child view
main view:
var viewMain = Ti.UI.createView();
viewManin.layout = 'vertical';
viewManin.backgroundColor = 'transparent';
viewManin.width = deviceWidth;
child view1:
var viewChild1 = Ti.UI.createView();
viewChild1.layout = 'vertical';
viewChild1.height = 'auto';
viewChild1.backgroundColor = 'transparent';
viewChild1.width = deviceWidth;
child view2:
var viewChild2 = Ti.UI.createView();
viewChild2.layout = 'vertical';
viewChild2.height = 'auto';
viewChild2.backgroundColor = 'transparent';
viewChild2.width = deviceWidth;
adding views to the main view:
viewMain.add(viewChilde1);
viewMain.add(viewChilde2);
inside each Child view i have labels with variable text size so i can't define the height of the view's. wen I add the child views to the main view what happens is that the last added view occupies the entire main view. how ca i make that the two view appears on the screen?
@Manuel_Rodrigues! I think before you try to do that, you should take a piece of time to read the API of titanium. It's had a good state to explain the property Ti.UI.FILL, Ti.UI.SIZE and AUTO in different situation for you to apply them. Here, I had wrote an example for you:
var win = Ti.UI.createWindow({
width: '100%',
height: '100%'
});
var mainView = Ti.UI.createView({
width: '100%',
height: 'auto',
layout: 'vertical',
horizontalWrap: true
});
win.add(mainView);
var view1 = Ti.UI.createView({
top: 10,
left: 10,
width: '45%',
borderRadius: 5,
height: Ti.UI.SIZE,
backgroundColor: '#25649d'
});
win.add(view1);
var viewLabel1 = Ti.UI.createLabel({
font:{
fontSize: 16
},
width: 'auto',
height: 'auto',
color: 'black',
textAlign: 'left',
verticalAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
text: 'this is a very long long long long long long text.'
});
view1.add(viewLabel1);
var view2 = Ti.UI.createView({
top: 10,
right: 10,
width: 'auto',
borderRadius: 5,
height: Ti.UI.SIZE,
backgroundColor: '#25649d'
});
win.add(view2);
var viewLabel2 = Ti.UI.createLabel({
font:{
fontSize: 16
},
width: 'auto',
height: 'auto',
color: 'black',
textAlign: 'right',
verticalAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
text: 'yes, I had seen it!'
});
view2.add(viewLabel2);
If you run this code, it's should display like follow: