Flex4将滚动条添加到应用程序

时间:2011-01-18 17:04:47

标签: flex flex4 flexbuilder

我正在尝试创建一个minHeight = 600和minWidth = 800的登录页面。如果用户调整为较小的分辨率,则仅添加滚动条。我跟着tutorial。 码: main.xml中

<?xml version="1.0"?>
<!-- containers\application\AppSparkScroll.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           minWidth="800" minHeight="600"
           width="100%" height="100%"
           backgroundColor="#292929"
           skinClass="skins.CustomApplicationSkin">

<s:Panel title="Login" id="loginPanel" verticalCenter="0" horizontalCenter="0">

    <mx:Form>

        <mx:FormItem label="Username" width="100%">
            <s:TextInput width="100%" id="username" />
        </mx:FormItem>
        <mx:FormItem label="Password" width="100%">
            <s:TextInput width="100%" displayAsPassword="true" id="password" />
        </mx:FormItem>
        <mx:FormItem>
            <s:Button label="Login" id="loginButton" />
        </mx:FormItem>

    </mx:Form>

</s:Panel>

skins.CustomApplicationSkin.mxml

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

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

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

<!-- fill -->
<s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0">
    <s:fill>
        <s:SolidColor color="0xFFFFFF" />
    </s:fill>
</s:Rect>

<s:Scroller height="100%" width="100%">
    <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" />        
</s:Scroller>
</s:Skin>

2 个答案:

答案 0 :(得分:1)

同样的问题,我也遵循相同的教程。如果我将horizo​​ntalScrollPolicy =“on”verticalScrollPolicy =“on”添加到滚动条,可以看到滚动条,但即使浏览器大小小于内容大小,它们也不起作用。

答案 1 :(得分:0)

在index.html文件中,在样式声明中,粘贴以下代码,

html, body  {height:100%; width:100%; min-width:800px; min-height:600px; overflow:auto; position:absolute;}

我希望它应该有效。如果屏幕尺寸小于800X600,则会出现滚动条。