Flex Gumbo中如何设置DropDownList弹出菜单宽度的例子
By Minidxer | August 12, 2009
接下来的Flex Gumbo中如何通过width属性,设置DropDownList弹出菜单宽度。
下面是main.mxml:
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application name="Spark_DropDownList_skinClass_width_test"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/halo">
- <s:DropDownList id="dropDownList"
- labelField="label"
- requiresSelection="true"
- skinClass="skins.CustomDropDownListSkin"
- horizontalCenter="0"
- top="20">
- <s:dataProvider>
- <s:ArrayList>
- <fx:Object label="Adobe AIR" />
- <fx:Object label="ColdFusion" />
- <fx:Object label="Dreamweaver" />
- <fx:Object label="Flash" />
- <fx:Object label="Flash Player" />
- <fx:Object label="Fireworks" />
- <fx:Object label="Flex" />
- <fx:Object label="Illustrator" />
- </s:ArrayList>
- </s:dataProvider>
- </s:DropDownList>
- </s:Application>
下面是Skin类CustomDropDownListSkin.mxml的代码:
- <?xml version="1.0" encoding="utf-8"?>
- <s:SparkSkin name="CustomDropDownListSkin"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- alpha.disabled="0.5">
- <s:states>
- <s:State name="normal" />
- <s:State name="open" />
- <s:State name="disabled" />
- </s:states>
- <!-- host component -->
- <fx:Metadata>
- [HostComponent("spark.components.DropDownList")]
- </fx:Metadata>
- <s:PopUp id="popup" open.normal="false" open.open="true" includeIn="open"
- left="0" right="0" top="0" bottom="0"
- visible.open="true" visible.normal="false"
- placement="below">
- <s:Group id="dropDown"
- maxHeight="134" minHeight="22" visible.open="true" visible.normal="false"
- width="200">
- <!-- border -->
- <s:Rect left="0" right="0" top="0" bottom="0">
- <s:stroke>
- <s:SolidColorStroke color="0x686868" weight="1"/>
- </s:stroke>
- </s:Rect>
- <!-- fill -->
- <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
- <s:fill>
- <s:SolidColor id="bgFill" color="0xFFFFFF" />
- </s:fill>
- </s:Rect>
- <s:Scroller left="1" top="1" right="1" bottom="1" >
- <s:DataGroup id="dataGroup" itemRenderer="spark.skins.default.DefaultItemRenderer">
- <s:layout>
- <s:VerticalLayout gap="0" horizontalAlign="contentJustify"/>
- </s:layout>
- </s:DataGroup>
- </s:Scroller>
- <s:filters>
- <s:DropShadowFilter blurX="20" blurY="20" distance="5" angle="90" alpha="0.6" />
- </s:filters>
- </s:Group>
- </s:PopUp>
- <s:Button id="button" left="0" right="0" top="0" bottom="0" focusEnabled="false"
- skinClass="spark.skins.default.DropDownListButtonSkin" />
- <s:SimpleText id="labelElement" verticalAlign="middle"
- left="7" right="30" top="2" bottom="2" verticalCenter="1" />
- </s:SparkSkin>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
DropDownList, Gumbo |
No Comments » |
Tags: Gumbo, popUp, skinClass, width