2012-09-14 1 views
0

Flex3 코드로 일부 Flex3을 리팩터링하고 Spark TabBar 컨트롤에 문제가 있습니다. 모든 탭의 너비 아래로 크기를 조정할 때 4.5에서는 탭이 축소됩니다. 나는 Flex4로 이것을 보지 않을 것이고 어떤 인터넷 검색을 한 후에 나는 해결책을 찾지 못하는 것처럼 보일 수있다.Flex TabBar 탭의 표시 너비가 아래로 조정되지 않습니다.

TabBar의 minWidth가 모든 단추의 합계와 그 사이의 간격으로 설정됩니다.

아무 생각? 가장 도움이 될 것입니다. 나는 이것이 쉬울 것이라고 생각했지만 그것을 고칠 수 없었다.

<s:TabBar id="myTabBar" top="0" width="100%" dataProvider="{myTabs}" > 
    <s:layout> 
     <s:HorizontalLayout gap="1" variableColumnWidth="true" /> 
    </s:layout> 
</s:TabBar> 

업데이트 : 나는 그것이 이상적인 하나 확실하지 오전하지만 나는 해결책을 온
. 기본 TabBarSkin을 가져 와서 측정 방법을 추가하도록 수정했습니다. 측정 방법에서는 탭을 반복하고 레이블 객체를 찾은 다음 너비를 계산합니다. 이를 사용하여 부모 구성 요소의 maxWidth를 설정합니다. 그것은 작동하는 것처럼 보이지만이 방법에 대한 의견을 환영합니다. 위의 레이아웃 태그도 가져 왔습니다.

 protected override function measure():void 
     { 
      //TODO Auto-generated method stub 
      super.measure(); 


      // Calculate the maximum size of the button should stretch to and then set the host Component 
      // To the maxWidth. This is accomplished by iterating through the children of the dataGroup 
      // and then getting the label components from labelDisplay. Once you have that then we can 
      // get the PreferredBoundsWidth and add them all up. The left and right values are added in as 
      // that is the spacing on each side of the label. 
      var totalButtonWidth:Number = 0; 
      var tab:UIComponent; 
      var calculatedWidth:Number; 

      for (var i:int = 0; i < dataGroup.numElements; i++) 
      { 
       tab = dataGroup.getElementAt(i) as UIComponent; 
       calculatedWidth = 0; 
       if (tab.hasOwnProperty("labelDisplay")) 
       { 
        var tabLabel:Label = (tab["labelDisplay"] as Label); 
        calculatedWidth = tabLabel.getPreferredBoundsWidth() + tabLabel.left + tabLabel.right; 
       } 
       totalButtonWidth = totalButtonWidth + calculatedWidth; 

      } 

      hostComponent.maxWidth = totalButtonWidth; 
      trace("totalWidth is " + totalButtonWidth); 
     } 

나는 SDK에서 피부를 가지고 그것을 수정하고 바로 재사용 괜찮습니다, 기억 경우?

답변

1

예 업데이트에서 말씀하신 내용을 수행하는 것은 절대 가능합니다.

그러나 기존의 스킨을 수정하는 것보다 처음부터 자신의 스킨을 정의하는 것이 훨씬 쉽습니다. this 설명서를 살펴보십시오.

관련 문제