如何最大化Callout,以便占用屏幕上的最大可用空间?
我正在尝试to display a ViewNavigator in a Callout虽然它有效但显示的View
太窄了:
在同一个程序中,我有另一个Callout
并且足够宽:
它们之间唯一的两个区别是后者附加到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>
答案 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'属性。