flex setting button width to text width
I am creating a nav in flex that pulls in buttons dynamically from xml. THe problem i am having is setting the button width to the text width. currently the buttons are all the same width and if the text is larger then it just cuts off. I've tried a few ways of doing this:
- Setting button width to 100%
- On creation of the button try to set the width of the button to the text programmatically. Something like evt.target.width = evt.target.textW开发者_开发技巧idth;
Anyone know the correct way to do this?
By default, Flex stretches the Button control width to fit the size of its label, any icon, plus 6 pixels of padding around the icon. You can override this default width by explicitly setting the width property of the Button control to a specific value or to a percentage of its parent container. If you specify a percentage value, the button resizes between its minimum and maximum widths as the size of its parent container changes.
From Sizing a Button control section in this live docs page. As far as I can understand from this is, If you remove the width= form your code, it should give what you want.
精彩评论