Omu
Omu

Reputation: 71198

flex vbox child elements to take 100% of width without indicating width="100%"

is it possible to make the child elements of a vbox to occupy 100% of the width without indicating width=100% for each element ?

Upvotes: 1

Views: 1859

Answers (3)

Joel Hooks
Joel Hooks

Reputation: 6565

You could make the elements a custom component and specify width="100%" in the component. Otherwise, no.

You can also bind the width property to the parents width property, which would have much the same affect.

Upvotes: 2

Vinay Sajip
Vinay Sajip

Reputation: 99345

A VBox's layout algorithm will look at the children's width to decide how to lay them out. If you want to "automatically" set them to 100%, no matter what they are, then the way to do that is to trap when the child is added and set its percentWidth to 100 in the event handler, or else subclasses and loop over the children in a suitable overridden method e.g. createChildren.

Upvotes: 1

James Hay
James Hay

Reputation: 12700

No... you'll have to add a width for each button. The vbox will ask the Button how much space it wants to take up. So you need to tell the button to try and take 100% of the width.

It shouldn't be a problem and is quite common to have width and height attributes on the majority of components, both functional and layout.

Upvotes: 0

Related Questions