2012-05-10 37 views
1

我有一組與它2個圖形內側之間的間隙,我設置在該組的垂直佈局的間隙爲0,但仍有1個像素的2個圖形之間的間隙。任何想法如何擺脫這一點?軟硬度:圖形

<?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> 

回答

1

您的問題的簡單答案是,差距似乎來自您給第一個圖形的明確高度。簡單地刪除它,差距就會消失。

的(IMO)更好的答案是,這代碼似乎有點令人費解創建簡單的圖形。

  • 沒有理由讓每一行都包含在Graphics類中。你可以擴展圖形來創建一個獨立的,可重用的圖形類。
  • 有一個用於繪製直線的Line類。更容易比使用Path

如果你絕對需要VerticalLayout,你可以重寫代碼:

<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>