import mx.collections.ArrayCollection; [Bindable] private var listData:ArrayCollection = new ArrayCollecti_file.list添加滚动条">
当前位置:   article > 正文

为List组件添加可随内容变化的滚动条_file.list添加滚动条

file.list添加滚动条

<?xml version="1.0" encoding="utf-8" ?>

 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();">
 <mx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
         
         [Bindable]
         private var listData:ArrayCollection = new ArrayCollection();
         
         private var arrs:Array = [{label:"Lorem ipsum dolor sit amet, consectetuerad xxxxxYYYYYY."},
         {label:"Donec sit amet dui nec pede aliquam auctor."},
         {label:"Integer vestibulum sodales dui."},
         {label:"Lorem ipsum dolor sit amet, consectetuerad xxxxxYYYYYY."},
         {label:"Donec sit amet dui nec pede aliquam auctor."},
         {label:"Integer vestibulum sodales dui."}];
          
         
            private function init():void {
             listData.source = arrs;
                myAutoSizeList.maxHorizontalScrollPosition = getMaxLabelLength() - myAutoSizeList.columnWidth;
               
            }
            private function getMaxLabelLength():int{
             var maxLabelLength:int = 0;
             for(var i:int=0;i<arrs.length;i++){
              var eachLabelLength:int = measureText(arrs[i].label).width*1.1;
              if(eachLabelLength>maxLabelLength){
               maxLabelLength = eachLabelLength;
              }
             }
             return maxLabelLength;
            }
       
  ]]>
 </mx:Script>
 
  <mx:List id="myAutoSizeList" dataProvider="{listData}" horizontalScrollPolicy="auto" rowCount="6" width="200" />
  </mx:Application>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/231532
推荐阅读
相关标签
  

闽ICP备14008679号