下面的例子展示了如何通过设置horizontalAlign风格来指定Flex中TabBar控件中Tab的水平位置。
下面是完整代码:
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
-
- <mx:Style>
- TabBar {
- tabStyleName: myCustomTabStyleName;
- selectedTabTextStyleName: myCustomSelectedTabTextStyleName;
- }
-
- .myCustomTabStyleName {
- fillColors: haloBlue, haloGreen;
- fillAlphas: 1.0, 1.0;
- }
-
- .myCustomSelectedTabTextStyleName {
- color: white;
- }
- </mx:Style>
-
- <mx:Array id="arr">
- <mx:Object label="Button" />
- <mx:Object label="ButtonBar" />
- <mx:Object label="ColorPicker" />
- <mx:Object label="ComboBox" />
- </mx:Array>
-
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="horizontalAlign:">
- <mx:ComboBox id="comboBox">
- <mx:dataProvider>
- <mx:Array>
- <mx:Object label="left" />
- <mx:Object label="center" />
- <mx:Object label="right" />
- </mx:Array>
- </mx:dataProvider>
- </mx:ComboBox>
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
-
- <mx:Box backgroundColor="black">
- <mx:TabBar id="tabBar"
- dataProvider="{arr}"
- width="500"
- tabWidth="100"
- tabHeight="40"
- horizontalAlign="{comboBox.selectedItem.label}"
- direction="horizontal" />
- </mx:Box>
-
- </mx:Application>
原文作者:Peter deHaan 翻译:minidxer
上一篇:Flex教程-使用行为 下一篇:【Flex开发框架】Cairngorm的学习笔记