左侧和右侧具有一种颜色的 Flex 按钮另一个在右边
我有一个 Flex 按钮。我需要左边一种颜色,右边另一种颜色。我不需要它是渐变。只是纯色。就像左边的绿色和右边的绿色一样右侧为红色。我真的不想使用图像——只是因为它可能需要我很长时间才能做到。
通过 Flex Builder 中的 Flex Properties 实现的渐变似乎仅垂直应用,而不是水平应用。
我还尝试制作 2 个按钮,每个按钮宽度为(原始的)的一半,然后将其放入 HBox 中。确实将它们紧密地包装在一起,这样它们看起来就像一个具有两种颜色的按钮。它工作正常,但我在想是否有更好的方法。
谢谢。
I have a Flex button. I need one color on the left and another on the right. I don't need it to be a gradient. Just solid colors. Like green on left & red on right. I really don't want to use an image -- just because it'll probably take me a long time to do it.
The gradients via Flex Properties in Flex Builder seems to apply only vertically, not horizontally.
I also tried to make 2 button, each half width (of original), and putting it into a HBox & really packing them close so they'll look like a single button with 2 colors. It works OK, but I was thinking if there was a better way.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为执行此类操作的正确方法是创建一个自定义组件,然后重写绘图方法并以两种颜色绘制,并具有关联的属性等。
您使用的解决方案是最简单的,因此您应该保持这样,除非您想经历创建自定义组件的麻烦(这还不错,因为 Flex 是开源的,您可以看到如何原始按钮已编码,并从那里进行修改)。
I think the proper way to do something like this is to create a custom component and then override the drawing method and draw in two colors, with the associated properties and such.
The solution you used is the simplest, so you should keep it like that unless you want to go through the trouble of creating the custom component (It's not THAT bad since Flex is open source and you can see how the original button is coded, and modify from there).
你可以使用 degrafa 为按钮设置皮肤
you could use degrafa to skin the button
此链接 http://blog.timeister.com/2009 /01/16/flex-custom-button-skin/ 提供了一种很好的方法来完成我上面想要的操作。它需要 2 个类:一个是 ButtonSkin 的子类,一个是 ButtonSkin 的子类。另一个按钮。通过 CSS 将它们链接起来并在 mxml 中使用它们。简单&简单的。
This link http://blog.timeister.com/2009/01/16/flex-custom-button-skin/ provides a nice way to do exactly what I wanted above. It needs 2 classes: one subclasses ButtonSkin & the other Button. Link them both via CSS and use them in mxml. Simple & easy.