Flex中通过horizontalAlign和verticalAlign样式调整Tile容器横向和竖向对齐方式的例子

By Minidxer | August 3, 2008

接下来的例子演示了Flex中如何通过horizontalAlign和verticalAlign样式,调整Tile容器横向和竖向对齐方式。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white">
  6.  
  7.     <mx:ApplicationControlBar dock="true">
  8.         <mx:Label text="horizontalAlign:" />
  9.         <mx:ComboBox id="hAlign">
  10.             <mx:dataProvider>
  11.                 <mx:String>left</mx:String>
  12.                 <mx:String>center</mx:String>
  13.                 <mx:String>right</mx:String>
  14.             </mx:dataProvider>
  15.         </mx:ComboBox>
  16.  
  17.         <mx:Spacer width="100" />
  18.  
  19.         <mx:Label text="verticalAlign:" />
  20.         <mx:ComboBox id="vAlign">
  21.             <mx:dataProvider>
  22.                 <mx:String>top</mx:String>
  23.                 <mx:String>middle</mx:String>
  24.                 <mx:String>bottom</mx:String>
  25.             </mx:dataProvider>
  26.         </mx:ComboBox>
  27.     </mx:ApplicationControlBar>
  28.  
  29.     <mx:Tile id="tile"
  30.             backgroundColor="haloSilver"
  31.             tileHeight="50"
  32.             tileWidth="50"
  33.             horizontalAlign="{hAlign.selectedItem}"
  34.             verticalAlign="{vAlign.value}">
  35.         <mx:VBox width="30" height="30" backgroundColor="red" />
  36.         <mx:VBox width="30" height="30" backgroundColor="red" />
  37.         <mx:VBox width="30" height="30" backgroundColor="red" />
  38.         <mx:VBox width="30" height="30" backgroundColor="red" />
  39.         <mx:VBox width="30" height="30" backgroundColor="red" />
  40.         <mx:VBox width="30" height="30" backgroundColor="red" />
  41.         <mx:VBox width="30" height="30" backgroundColor="red" />
  42.     </mx:Tile>
  43.  
  44. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Flex | No Comments » | 326 views Tags: , , ,

Search Posts