Flex的自定义按钮组件 [英] Flex custom button component

查看:140
本文介绍了Flex的自定义按钮组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的自定义按钮,看起来像下面的按钮样本。 更具体而言,我想由最大的单词的标签的宽度(拉长在我的例子即宽度)来确定该按钮的宽度。标签必须包裹,不会截断。 而我想要的图标的顶边和我的按钮的上边缘之间只有一个像素。 我已经试过很多东西,但都无济于事为止。我已经减少了horizo​​ntalGap和的verticalGap为零,并填充到零。但是,仍然一无所获。请大家帮帮忙。

I want my custom button to look like the button sample below. More specifically, I want the width of the button to be determined by the width of the largest word in the label (i.e. width of "Elongated" in my example). The label must wrap, not truncate. And I want only one pixel between the top edge of the icon and my button's top edge. I have tried lots of things but to no avail so far. I have reduced the horizontalGap and verticalGap to zero and padding to zero. But still nothing. Please help.

这就是我现在所拥有的:

Here's what I have right now:

<mx:Button  top="0" cornerRadius="2" paddingLeft="0" paddingRight="0" leading="0" letterSpacing="0" paddingTop="0" paddingBottom="0" verticalGap="0" horizontalGap="0" textAlign="center" labelPlacement="bottom" icon="{MyIcon}" height="60" width="75" label="Elongated Label" fontSize="10" />

推荐答案

这不是在所有的简单。

您需要创建自己的按钮,

You will need to create your own button,

public class Mybutton extends Button {...}

覆盖createChildren并设置IUITextField的的自动换行用于标签为true。

override createChildren and set the word wrap of the IUITextField used for the label to true.

覆盖措施,并使用自己的线指标来确定宽度,该按钮应。如果你得到了正确的措施,该按钮将奠定自己的方法正确。

override measure and use your own line metrics to determine the width that the button should be. If you get the measure right, the button will lay itself out properly.

这篇关于Flex的自定义按钮组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆