自定义 SkinnableContainer 皮肤边框

发布于 2024-11-04 09:47:52 字数 1174 浏览 0 评论 0原文

我有一个 SkinnableContainer,我想为其添加边框。我已经创建了一个外观类,它成功地在容器的所有四个侧面周围创建了 1 像素边框,但是,我希望边框仅适用于容器的顶部和底部,而不是侧面(左、右)。我怎样才能实现这样的目标?我已附上我当前的皮肤类别。请帮忙!提前致谢。

<?xml version="1.0" encoding="utf-8"?>
<!-- containers\spark\mySkins\MyBorderSkin.mxml -->
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark" >

<fx:Metadata>
    [HostComponent("spark.components.SkinnableContainer")]
</fx:Metadata>

<!-- Define the skin states. -->
<s:states>
    <s:State name="normal" />
    <s:State name="disabled" />
</s:states>

<!-- Define a Rect to fill the area of the skin. -->
<s:Rect x="0" y="0"
        height="100%" width="100%">
    <s:stroke>
        <s:LinearGradientStroke weight="1"/>
    </s:stroke>         
</s:Rect>

<!-- Define the content area of the container. -->
<s:Group id="contentGroup"
         left="5" right="5" top="2" bottom="2">
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
</s:Group>        
</s:Skin>

I have a SkinnableContainer that I would like to add a border to. I have already created a skin class that creates a 1 pixel border around all four sides of the container successfully, however, I would like the border to only be for the top and bottom of the container, not the sides (left, right). How can I achieve such a thing? I have attached my current skin class. Please help! Thanks in advance.

<?xml version="1.0" encoding="utf-8"?>
<!-- containers\spark\mySkins\MyBorderSkin.mxml -->
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark" >

<fx:Metadata>
    [HostComponent("spark.components.SkinnableContainer")]
</fx:Metadata>

<!-- Define the skin states. -->
<s:states>
    <s:State name="normal" />
    <s:State name="disabled" />
</s:states>

<!-- Define a Rect to fill the area of the skin. -->
<s:Rect x="0" y="0"
        height="100%" width="100%">
    <s:stroke>
        <s:LinearGradientStroke weight="1"/>
    </s:stroke>         
</s:Rect>

<!-- Define the content area of the container. -->
<s:Group id="contentGroup"
         left="5" right="5" top="2" bottom="2">
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
</s:Group>        
</s:Skin>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装纯掩盖桑 2024-11-11 09:47:52

使用类似:

<s:Line left="0" top="0" right="0">
    <s:stroke>
        <s:LinearGradientStroke weight="1"/>
    </s:stroke>
</s:Line>

<s:Line left="0" bottom="0" right="0">
    <s:stroke>
        <s:LinearGradientStroke weight="1"/>
    </s:stroke>
</s:Line>

代替 Rect 声明。

Use something like:

<s:Line left="0" top="0" right="0">
    <s:stroke>
        <s:LinearGradientStroke weight="1"/>
    </s:stroke>
</s:Line>

<s:Line left="0" bottom="0" right="0">
    <s:stroke>
        <s:LinearGradientStroke weight="1"/>
    </s:stroke>
</s:Line>

instead of your Rect declaration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文