我正在尝试将带有背景图像的自定义皮肤添加到我的应用程序中,该皮肤完全适合任何设备的整个屏幕。这是皮肤:
<?xml version="1.0" encoding="utf-8"?>
<s:Skin name="CustomMainSkin"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
alpha.disabled="0.5" >
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
</s:states>
<fx:Metadata>
<![CDATA[
[HostComponent("spark.components.Application")]
]]>
</fx:Metadata>
<!-- fill -->
<s:BitmapImage id="img"
source="assets/background.jpg"
scaleMode="stretch"
fillMode="scale"
smooth="true"
left="0" right="0"
top="0" bottom="0" />
<s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" minWidth="0" minHeight="0" />
如果我在应用程序上设置皮肤,一切看起来都很好,图像会根据屏幕需要调整大小,但所有组件都会消失,我无法编辑任何视图。
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="240"
xmlns:components="views.*"
creationComplete="removeTab1DefaultView(event)"
skinClass="skins.CustomMainSkin" >
<s:ViewNavigator label="Main view" firstView="views.MainView"/>
<s:ViewNavigator label="Online Rankings" firstView="views.RankingsOnline"/>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:TabbedViewNavigatorApplication>
我尝试使用 SkinnableContainer 直接在视图中设置皮肤。组件以这种方式可见,但图像不会调整大小并且比屏幕大很多。
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="MainView"
actionBarVisible="false"
tabBarVisible="false"
>
<s:SkinnableContainer skinClass="skins.CustomMainSkin" >
<s:NavigatorContent id="gameBoard" >
</s:NavigatorContent>
<s:Group x="27" y="133" width="297" height="388">
<s:Button left="33" right="36" top="39" bottom="281" label="Start Game"
horizontalCenter="-2" verticalCenter="-121" click="button1_clickHandler(event)"/>
<s:Button x="34" y="146" width="228" label="Rankings" click="rankingsAction(event)"/>
<s:Button x="32" y="252" width="228" label="Quit"/>
</s:Group>
</s:SkinnableContainer>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:View>
我怎样才能做到这一点?这似乎真的很难和不自然。
谢谢