Flex: how to reduce the distance between components

How can I reduce the space between my links and inside each linkButton?

I set padding to 0, but that was already 0. I was able to change the height of the LinkButtons, but I can't do that with the width, because the text is dynamic.

<mx:Repeater id="bookmarksRepeater" dataProvider="{dataManager.bookmarksList}">
    <mx:HBox>
        <mx:VBox>
        <mx:HBox>
            <mx:Text >
               <mx:text> {String(bookmarksRepeater.currentItem.name)}</mx:text>
            </mx:Text>
            <mx:LinkButton height="16" rollOverColor="#FFA500" label="Visit" />
            <mx:LinkButton height="16" rollOverColor="#FFA500" label="Add" />
            <mx:LinkButton height="16" rollOverColor="#FFA500" label="Save" />
        </mx:HBox>
     <mx:HBox>
        <mx:Repeater id="tagsRepeater" dataProvider="{bookmarksRepeater.currentItem.tags}">
           <mx:LinkButton height="14" color="0x0033CC" rollOverColor="#FFA500" fontSize="8" label="{String(tagsRepeater.currentItem.name)}"/>
     </mx:Repeater>
     </mx:HBox>
    </mx:VBox>
     <mx:Text height="16" color="0x0033CC" fontWeight="bold" >
    <mx:text> {String(bookmarksRepeater.currentItem.popularity)} </mx:text>
       </mx:Text>
    </mx:HBox>
</mx:Repeater> 

      

+2


a source to share


2 answers


Your repeater is inside the HBox, which has a horizontal distance by default. To remove this distance, set the horizontal border to 0:



 <mx:HBox horizontalGap="0">
    <mx:Repeater id="tagsRepeater" dataProvider="{bookmarksRepeater.currentItem.tags}">
       <mx:LinkButton height="14" color="0x0033CC" rollOverColor="#FFA500" fontSize="8" 
           label="{String(tagsRepeater.currentItem.name)}"/>
    </mx:Repeater>
 </mx:HBox>

      

+5


a source


To set the width of the LinkButtons dynamically, you probably have to do so by overriding the commitProperties of your container class, and for each LinkButton, compute the text metrics:

var m: TextLineMetrics = linkButton.measureText (lb.label);



Then you should be able to use the calculated metrics to set the exact width for each LinkButton.

Another way to do this would be to listen for the tagged events associated with the LinkButton and then force the width reallocation in the listener.

0


a source







All Articles