如何在Flex4.5中创建组件(将其用于android..)它有一个textInput,在它的右边有一个按钮,这样按钮就具有固定的大小,并且textInput展开以填充组件的父级的剩余空间?
这就是组件..
<s:HGroup>
<s:TextInput width="????"/>
<s:Button width="37" height="37" />
</s:HGroup>当然,我不知道在宽度中添加什么..我是否还应该指定HGroup的宽度?
发布于 2013-02-01 03:59:51
Flex根据子对象的父对象确定相对大小。
如果你不给父组一个宽度,那么TextInput就不知道它应该填充到100%。
<s:HGroup width="100%">
<s:TextInput width="100%"/>
<s:Button width="37" height="37" />
</s:HGroup>作为对“将它们都设置为100%”答案的附注。Flex将允许您将多个百分比宽度设置为100%。2最终将具有相同的权重。所以
<s:HGroup width="100%">
<s:TextInput width="100%"/>
<s:Button width="100%"/>
</s:HGroup>将产生两个组件,这两个组件都占据了半个屏幕。
<s:HGroup width="100%">
<s:TextInput width="200%"/>
<s:Button width="100%"/>
</s:HGroup>将产生一个两倍于按钮宽度的TextInput
如果您想从ActionSript而不是MXML设置基于百分比的高度和宽度,则需要指定textInput.percentWidth = 100;
发布于 2011-11-01 13:07:18
<s:HGroup width="100%">
<s:TextInput width="width" />
<s:Button width="37" />
</s:Group>这里
width = [[android screen width (or group width) - 37 ] / android screen width (or group width) ] * 100它的百分比..
或者尝试将两者都设置为100%。这也许就是问题所在。
编辑:
只需在应用程序中获取屏幕尺寸即可。以下是指向该问题的链接。How to get screen dimensions和here
发布于 2011-11-01 13:10:37
试试这个:
<fx:Script>
<![CDATA[
import spark.components.Button;
private function onCreate():void
{
var yourButton:Button = new Button();
yourButton.width = 37;
yourButton.x = 10;
yourButton.y = 100;
text.addChild(yourButton);
}
]]>
</fx:Script>
<s:TextInput borderVisible="true" id="text" height="100%" width="100%" creationComplete="onCreate()" />https://stackoverflow.com/questions/7960972
复制相似问题