如何最大化spark.components.Callout?附上截图

时间:2012-12-05 17:26:28

标签: actionscript-3 flex flex4 flex4.6 callout

如何最大化Callout,以便占用屏幕上的最大可用空间?

我正在尝试to display a ViewNavigator in a Callout虽然它有效但显示的View太窄了:

enter image description here

在同一个程序中,我有另一个Callout并且足够宽:

enter image description here

它们之间唯一的两个区别是后者附加到CalloutButton而后者包含我设置的自定义Score组件:

    override protected function measure():void {
        super.measure();
        measuredWidth = Capabilities.screenResolutionX;
        measuredHeight = Capabilities.screenResolutionY;
    }

我一直盯着Callout.as代码,但找不到办法欺骗它占用大部分可用空间。

我的自定义mxml组件非常简单:

PlayerInfo.mxml:

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

    <fx:Script>
        <![CDATA[
            [Bindable]
            public var userid:String;
        ]]>
    </fx:Script>

    <s:ViewNavigator 
        firstView="views.Profile"
        firstViewData="{userid}">
        <s:navigationContent>
            <s:Button label="Close" click="close()" />
        </s:navigationContent>
    </s:ViewNavigator>

</s:Callout>        

1 个答案:

答案 0 :(得分:1)

Callout扩展了Container,因此您不应该将宽度和高度设置为100%。
此外,在Callout代码中有一个方法:

/**
 *  @private
 *  Force a new measurement when callout should use it's screen-constrained
 *  max size.
 */
private function invalidateMaxSize():void
{
    // calloutMaxWidth and calloutMaxHeight don't invalidate 
    // explicitMaxWidth or explicitMaxHeight. If callout's max size changes
    // and explicit max sizes aren't set, then invalidate size here so that
    // callout's max size is applied.
    if (!canSkipMeasurement() && !isMaxSizeSet)
        skin.invalidateSize();
}

因此,尝试设置'explicitMaxWidth'和'explicitMaxHeight'属性。