1.使用外部样式表
<mx:Style source="myStyle.css"/>
2.在内部定义一个自定义样式表
<mx:Style>
.myFontStyle { fontSize: 15 }
</mx:Style>
<mx:Button id="myButton" styleName="myFontStyle" label="Click Here"/>
.myFontStyle { fontSize: 15 }
</mx:Style>
<mx:Button id="myButton" styleName="myFontStyle" label="Click Here"/>
3.定义整体控件样式
<mx:Style>
Button { fontSize: 15 }
</mx:Style>
<mx:Button id="myButton" label="Click Here"/>
Button { fontSize: 15 }
</mx:Style>
<mx:Button id="myButton" label="Click Here"/>
4.使用StyleManager类设置样式
getStyleDeclaration()方法获取样式名称,然后使用setStyle()方法定义样式
StyleManager.getStyleDeclaration("TextArea").setStyle("fontSize",15);
5.直接用控件的setStyle()方法
myButton.setStyle("fontSize", 15);
6.在控件中直接使用样式属性定义
<mx:Button id="myButton" fontSize="15" label="My Button"/>
本文介绍了六种不同的Flex控件样式设置方法:使用外部样式表、内部定义自定义样式表、定义整体控件样式、使用StyleManager类设置样式、直接用控件的setStyle()方法以及在控件中直接使用样式属性定义。
356

被折叠的 条评论
为什么被折叠?



