Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex:图形之间的间隙_Apache Flex_Graphic_Gaps In Visuals - Fatal编程技术网

Apache flex Flex:图形之间的间隙

Apache flex Flex:图形之间的间隙,apache-flex,graphic,gaps-in-visuals,Apache Flex,Graphic,Gaps In Visuals,我有一个里面有2个图形的组,我将组的垂直布局中的间距设置为0,但两个图形之间仍然有1个像素的间距。你知道怎么摆脱这个吗 <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="

我有一个里面有2个图形的组,我将组的垂直布局中的间距设置为0,但两个图形之间仍然有1个像素的间距。你知道怎么摆脱这个吗

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <s:Group>
        <s:layout>
            <s:VerticalLayout gap="0"/>
        </s:layout>
        <s:Graphic height="100">
            <s:Path data="M 50 0 L 50 100 Z" height="100">
                <s:stroke>
                    <s:SolidColorStroke color="#333333"/>
                </s:stroke>
            </s:Path>
        </s:Graphic>
        <s:Graphic height="1">
            <s:Path data="M 0 0 L 100 0 Z" height="1">
                <s:stroke>
                    <s:SolidColorStroke color="#333333"/>
                </s:stroke>
            </s:Path>
        </s:Graphic>
    </s:Group>
</s:Application>

您的问题的简单答案是,间距似乎来自您给出的第一张图形的明确高度。只要将其移除,间隙就会消失

(IMO)更好的答案是,对于创建简单图形来说,这段代码似乎有点复杂

  • 没有理由将每一行包装在
    Graphics
    类中。您可以扩展Graphic来创建一个独立的、可重用的Graphic类
  • 有一个绘制直线的
    Line
    类。比使用路径更容易
如果您确实需要
垂直布局
,您可以这样重写该代码:

<s:Group>
    <s:layout>
        <s:VerticalLayout gap="0" horizontalAlign="center" />
    </s:layout>
    <s:Line height="100">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
    <s:Line width="100">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
</s:Group>

但如果出于某种原因,您并不真正需要它,它甚至可以简化为:

<s:Group>
    <s:Line height="100" horizontalCenter="0">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
    <s:Line width="100" bottom="0">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
</s:Group>

您的问题的简单答案是,间距似乎来自您给出的第一张图形的明确高度。只要将其移除,间隙就会消失

(IMO)更好的答案是,对于创建简单图形来说,这段代码似乎有点复杂

  • 没有理由将每一行包装在
    Graphics
    类中。您可以扩展Graphic来创建一个独立的、可重用的Graphic类
  • 有一个绘制直线的
    Line
    类。比使用路径更容易
如果您确实需要
垂直布局
,您可以这样重写该代码:

<s:Group>
    <s:layout>
        <s:VerticalLayout gap="0" horizontalAlign="center" />
    </s:layout>
    <s:Line height="100">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
    <s:Line width="100">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
</s:Group>

但如果出于某种原因,您并不真正需要它,它甚至可以简化为:

<s:Group>
    <s:Line height="100" horizontalCenter="0">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
    <s:Line width="100" bottom="0">
        <s:stroke>
            <s:SolidColorStroke color="#333333" />
        </s:stroke>
    </s:Line>
</s:Group>