Reputation: 560
I have a view that contains my layout . when a button is pressed the main view is resized but all it children keep the same height and width. How can I resize all objects that are inside the main view?
for example when I have this:
var view = Ti.UI.createView({
height:deviceHeight,
width:deviceWidth
});
view.add(Ti.UI.createView({
height:Ti.UI.SIZE,
width:Ti.UI.SIZE
}));
how can I for example resize the secunde view that is added to the firs one?
I'm developing my app in titanium in classic mode.
Upvotes: 1
Views: 78
Reputation: 24815
Because you specified SIZE
as the size for a view it will keep that size. As you didn't specify it needed to have a size based on the parent.
The only way to do this is, if you specify the height and width as a percentage.
If your content is in fact dynamic you could trick it.
When the button is pressed convert your view
to an image with var image = view.toImage()
.
Then, hide all the content you've added and insert the image into your view:
var image = view.toImage()
var img = Ti.UI.createImageView({
height: '100%',
width: '100%',
image: image
});
view.add(img);
Then you can resize your view
and the content will resize too.
Upvotes: 1