如何在两个组件周围绘制连接边框?
在我自己解决这个问题之前,我认为我选择了 SO 社区的想法。
假设我有一个使用按钮的Image
。默认情况下,图像周围没有边框。单击此图像
将导致另一个组件显示在其下方或旁边。当显示第二个组件时,我想在 Image
和第二个组件周围绘制一个连接边框。
默认情况下,第二个组件不可见。只有使用 popupManager
、PopUpAnchor
单击 Image
后才可见,设置 visible
属性, 点击前的示例
:
+--------------------------------+
| |
| XXX <-- My Image |
| XXX |
| |
| |
| |
| |
| |
| |
| |
+--------------------------------+
点击后的示例:
+--------------------------------+
| +---+ |
| |XXX| <-- My Image |
| |XXX|_______________ |
| | | |
| | My Second | |
| | Component | |
| | | |
| | | |
| +-------------------+ |
| |
+--------------------------------+
创建这样的东西有多困难?
Before I tackled this myself, I thought I pick the minds of the SO community.
Let's assume I have an Image
that's used a button. By default, the image has no border around it. Clicking on this Image
will cause another component be displayed beneath it or next to it. When the second component is displayed, I want to draw a joined border around the Image
and the second component.
The second component would not be visible by default. It would only be visible after clicking on the Image
by using the popupManager
, PopUpAnchor
, setting the visible
property, etc.
Example before clicking:
+--------------------------------+
| |
| XXX <-- My Image |
| XXX |
| |
| |
| |
| |
| |
| |
| |
+--------------------------------+
Example after clicking:
+--------------------------------+
| +---+ |
| |XXX| <-- My Image |
| |XXX|_______________ |
| | | |
| | My Second | |
| | Component | |
| | | |
| | | |
| +-------------------+ |
| |
+--------------------------------+
How difficult would it be to create something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你使用的是flex4/spark,那么你应该考虑换肤(无论如何,borderSides样式仅在Halo中可用)。
这是一个小示例,用于实现图像中显示的行为:
它使用具有两种状态(折叠和展开)的自定义组件。
文本仅在展开状态下附加,边框皮肤也是如此。
为此,您需要两个皮肤类,它们将应用于图像组件和文本组件的父组件。
应用程序:
ExpandableImage.mxml //具有两种状态的自定义组件
MyImageSkin.as //要应用于图像组件父级的皮肤
MyDetailsSkin.as //要应用于文本父级的皮肤
我真的希望这有帮助
If you are using flex4 / spark, then you should consider skinning (anyway, the borderSides style is available only in Halo).
here is a small sample to achieve the behavior shown at the images:
It uses a custom component with two states (collapsed and expanded).
The text is only attached in the expanded state, and so are the border skins.
For this you'll need two skin classes that will be applied to the image- and to the text component's parent.
The Application:
ExpandableImage.mxml //the custom component with two states
MyImageSkin.as //the skin to be applied on the image component's parent
MyDetailsSkin.as //the skin to be applied on the text's parent
i really hope this helps
很确定你可以使用样式来做到这一点
添加第三个容器,我用 ****
标记
关闭我的新容器的顶部和右侧边框(***)
关闭图像容器的底部边框
关闭第二个组件的顶部边框
Pretty sure you can do this with styles
Add a third container i marked with ****
turn the top and right borders off on my new container(***)
turn the bottom border off on your image container
turn the top border off on your second component