? Spark容器的滚动条不像Halo一样会自动加载,它已被独立出来,需要我们自行设计。
? 一、使用滚动组件Scroller包含需要滚动的容器
? 二、对于List等基于列表的组件,Scroller已加到其skinclass中,需要的话,可以重写它们的skinclass来控制Scroller
?? 1、例如,Spark 容器 Group 和 DataGroup 都是轻量级的基本的构造块类。即便如此它们支持滚动,它们不会像 Halo 那样自动装配滚动条。Spark 提供底层 APIs 帮助手动为 Group 和 DataGroup 挂接滚动条-clipAndEnableScrolling,horizontalScrollPosition,verticalScrollPosition,contentWidth,contentHeight
。但同样有一个组件简化了这一过程。将 Group 或 DataGroup 嵌入到 Scroller 中就可以了,Scroller 会处理挂接以及在必要时显示滚动条。
<s:Scroller width="200"> <s:Group> <s:layout> <s:HorizontalLayout gap="0" verticalAlign="justify"/> </s:layout> <s:Button label="one"/> <s:Button label="two"/> <s:Button label="three"/> <s:Button label="four"/> <s:Button label="five"/> </s:Group> </s:Scroller>
? 2、事实上,这正是其他Spark容器(如 List )实现滚动的具体过程。它们的皮肤中包含一个 contentGroup
或 dataGroup
,并且被放置在Scroller中了。查看默认的List皮肤 (spark/skins/spark/ListSkin.mxml) 就会发现这一点。
... <!--- The Scroller component to add scroll bars to the list. --> <s:Scroller left="0" top="0" right="0" bottom="0" id="scroller" minViewportInset="1" focusEnabled="false"> <!--- The container for the data items. --> <s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer"> <s:layout> <s:VerticalLayout gap="0" horizontalAlign="contentJustify" /> </s:layout> </s:DataGroup> </s:Scroller> ...
出处:http://flex4jiaocheng.com/blog/266