Flex:如何减少组件之间的间距
如何减少 linkButton 之间和每个 linkButton 内部的空间?
我已经将 padding 设置为 0 但它已经是 0 了。 我只能更改 LinkButton 的高度,但无法更改宽度,因为文本是动态的。
<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>
how can I reduce the space between my linkButtons and inside each linkButton ?
I've set padding to 0 but it was already 0.
I've been able to only change the height of the LinkButtons, but I cannot 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的中继器位于 HBox 内,默认情况下设置了水平间距。要删除此间距,请将水平间隙设置为 0:
Your Repeater is inside an HBox, which has horizontal spacing set by default. To remove this spacing, set the horizontalGap to 0:
要动态设置 LinkButton 的宽度,您可能必须通过重写容器类的 commitProperties 来实现,并为每个 LinkButton 计算文本指标:
var m:TextLineMetrics = linkButton.measureText(lb.label);
然后您应该能够使用计算出的指标为每个 LinkButton 设置精确的宽度值。
另一种方法是侦听 LinkButton 上的 labelChanged 事件,然后在侦听器中强制重新计算宽度。
To set the width of the LinkButtons dynamically, you will probably have to do it by overriding commitProperties of your container class, and for each LinkButton calculate the text metrics:
var m:TextLineMetrics = linkButton.measureText(lb.label);
Then you should be able to use the calculated metrics to set a precise width value for each LinkButton.
Another way to do it would be to listen for labelChanged events on the LinkButton, and then force a width recalculation in the listener.