Flex中如何通过tabStyleName, tabWidth和textAlign样式,设置TabBar控件内文本对齐方式

main.mxml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Applicationname="TabBar_tabStyleName_textAlign_test"
  3. xmlns:mx="http://www.adobe.com/2006/mxml"
  4. layout="vertical"
  5. verticalAlign="middle"
  6. backgroundColor="white">
  7. <mx:Style>
  8. .customTabStyleName {
  9. textAlign: center;
  10. }
  11. </mx:Style>
  12. <mx:Script>
  13. <![CDATA[
  14. import mx.events.ListEvent;
  15. private function comboBox_change(evt:ListEvent):void {
  16. var cssObj:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".customTabStyleName");
  17. cssObj.setStyle("textAlign", comboBox.selectedItem.label);
  18. }
  19. ]]>
  20. </mx:Script>
  21. <mx:Arrayid="comboBoxDP">
  22. <mx:Objectlabel="left" />
  23. <mx:Objectlabel="center" />
  24. <mx:Objectlabel="right" />
  25. </mx:Array>
  26. <mx:Arrayid="tabBarDP">
  27. <mx:Objectlabel="Red" />
  28. <mx:Objectlabel="Orange" />
  29. <mx:Objectlabel="Yellow" />
  30. <mx:Objectlabel="Green" />
  31. <mx:Objectlabel="Blue" />
  32. </mx:Array>
  33. <mx:ApplicationControlBardock="true">
  34. <mx:FormstyleName="plain">
  35. <mx:FormItemlabel="textAlign:">
  36. <mx:ComboBoxid="comboBox"
  37. dataProvider="{comboBoxDP}"
  38. selectedIndex="1"
  39. change="comboBox_change(event);"/>
  40. </mx:FormItem>
  41. </mx:Form>
  42. </mx:ApplicationControlBar>
  43. <mx:TabBarid="tabBar"
  44. dataProvider="{tabBarDP}"
  45. tabWidth="120"
  46. tabStyleName="customTabStyleName"/>
  47. </mx:Application>

你可能感兴趣的:(xml,Flex,Adobe)