如何将背景图像添加到flex Android应用程序?

wtm*_*wtm 0 apache-flex android

如何添加背景图片?我只是绑定代码:

.bg{
backgroundImage:Embed(source="../../assets/Interaction-Screen_BG_pump.png");
}

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        actionBarVisible="true" enterFrame="view1_enterFrameHandler(event)"
        initialize="view1_initializeHandler(event)" menuKeyPressed="onMenu(event)"
        overlayControls="false" tabBarVisible="true" title="Interact"
                styleName="bg"
>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

还有,如何创建图像按钮?

Gun*_*son 5

要将背景图像添加到Flex Mobile View或应用程序,请首先创建您的皮肤类(我们称之为"ViewBackgroundSkin.mxml"):

<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark">

<fx:Metadata>
    [HostComponent("spark.components.View")]
</fx:Metadata>

<s:states>
    <s:State name="disabled" />
    <s:State name="normal" />
</s:states>

<s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0"  >
    <s:fill>
        <s:BitmapFill source="@Embed('assets/images/BackgroundImage.png')"/>
    </s:fill>
</s:Rect>

<s:Group id="contentGroup" width="100%" height="100%" minWidth="0" minHeight="0" />
Run Code Online (Sandbox Code Playgroud)

如果您希望图像平铺背景,请在BitmapFill上设置fillMode重复:

    <s:BitmapFill source="@Embed('assets/images/BackgroundImage.png')" fillMode="repeat" />
Run Code Online (Sandbox Code Playgroud)

在你的css文件中(我们称之为MyStyle.css)引用你的皮肤类:

s|View
{   
    skinClass: ClassReference("ViewBackgroundSkin");
} 
Run Code Online (Sandbox Code Playgroud)

在视图中,将样式源设置为css文件:

<fx:Style source="MyStyle.css"/> 
Run Code Online (Sandbox Code Playgroud)

或将样式添加到您的应用程序文件以设置整个应用程序的背景.