设置ActionBar在不同平台上Button的样式(Setting ActionBar Button style based on platform )

The typical iOS application has beveled buttons in the ActionBar. On Android, the buttons are flat. There is a property on ActionBar called defaultButtonAppearance which can be set to beveled or normal. By default it is set to normal. You can use CSS Media Queries to set the button style based on platform. This feature was introduced in Flex 4.5 and it works on desktop and mobile applications. The supported media features are application DPI (160, 240, 320) and platform (IOS, Android, QNX, Windows, Macintosh).

Here’s how you can switch between beveled and non-beveled buttons between Android and IOS:

<fx:Style>
	@namespace s "library://ns.adobe.com/flex/spark";
	@media (os-platform: "Android")
	{
		s|ActionBar
		{
			defaultButtonAppearance: normal;
		}
	}
	@media (os-platform: "IOS")
	{
		s|ActionBar
		{
			defaultButtonAppearance: beveled;
		}
	}
</fx:Style>

You would declare your media queries in the Style block of your main application mxml file. You can also declare them in any custom MXML components but the usual rules of CSS declarations apply. You can set type or class selectors in the main application file but only class selectors in custom components.

If you haven’t tried media queries yet, check it out. It’s an easy way to set styles for different devices without having to create a new theme or SWF for each.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值