弹性滚动条 [英] Flex ScrollBars

查看:29
本文介绍了弹性滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为我的 Flex 应用程序显示滚动条时遇到问题...我尝试了一个带有画布的基本应用程序,但滚动条从未出现在浏览器窗口中,尽管画布比屏幕上的尺寸大得多.有人可以帮忙吗?这是我的代码:

I have a problem displaying scrollbars for my Flex Application... I tried a basic very application with a canvas, but the scrollbars never appear on the browser window athough the canvas is much bigger than what can fit on the screen. Can someone please help? Here's my code :

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

    <mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto" 
    horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
    contentBackgroundColor="#080808"/>

    </s:Application>

推荐答案

您想要画布中的滚动条吗?还是在您的主要应用程序中?如果您想在画布中使用滚动条,只需添加超出画布高度和宽度的内容.它会神奇地"添加它们,因为这就是 MX/Halo 组件的作用.

Do you want the scroll bar in your canvas? Or in your main application? If you want scroll bars in your canvas, just add content that extends beyond the height and width of the canvas. It will "magically" add them, because that is way MX/Halo components role.

如果您希望在主应用程序中使用滚动条,则必须使用滚动条组件和组手动添加它们.概念上是这样的:

If you want scrollbars in your main application, you're going to have to add them manually, using a scroller component and a group. Conceptually something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

<s:Scroller height="100" width="100">
 <s:Group width="100%" height="100%" clipAndEnableScrolling="true">
    <mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto" 
    horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
    contentBackgroundColor="#080808"/>

 </s:Group>

</s:Scroller>

    </s:Application>

根据我的经验,您需要在滚动条上指定固定的高度和/或宽度才能显示滚动条.另外一定要对滚动条内的组进行clipAndenableScrolling,否则内容将显示在滚动条的视口之外——这有点违背目的.

In my experience you need to specify a fixed height and/or width on the scroller for the scroll bars to show up. Also be sure to clipAndenableScrolling on the group inside the scroller, or else the content will display beyond the scroller's viewport--which is kind of defeats the purpose.

来自 Adob​​e 的一些不错的信息.

这篇关于弹性滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆