根据屏幕分辨率动态调整组件大小
程序员文章站
2022-05-27 08:36:20
...
将代码写在组件的preInitialize事件监听器里面
简化案例如下:
简化案例如下:
<s:HGroup id="leftContianer" width="70%" preinitialize="leftContianer_preinitializeHandler(event)"> </s:HGroup> <s:HGroup id="rightSpacerContainer" width="30%" preinitialize="rightSpacerContainer_preinitializeHandler(event)"/> protected function leftContianer_preinitializeHandler(e:FlexEvent):void { var hg:HGroup=(e.currentTarget) as HGroup; if(hg!=null){ if(Capabilities.screenResolutionX<=1024){ hg.percentWidth=80; }else{ hg.percentWidth=70; } } } protected function rightSpacerContainer_preinitializeHandler(e:FlexEvent):void { var hg:HGroup=(e.currentTarget) as HGroup; if(hg!=null){ if(Capabilities.screenResolutionX<=1024){ hg.percentWidth=20; }else{ hg.percentWidth=30; } } }
上一篇: Ai怎么绘制卡通版冷漠无语的表情包?
下一篇: char*与char []的区别