對於移動Flex/Flash Builder,使用systemManager.screen.*
還是Stage.*
來檢測屏幕尺寸會更好 - 爲什麼?Flex 4.6 - 檢測手機屏幕尺寸 - systemManager.screen.width vs Stage.width
1
A
回答
2
在構建應用程序時,我認爲知道我必須使用的空間比知道實際屏幕尺寸更重要。
要獲取此信息,我將綁定到Flex框架並使用傳遞給updateDisplayList()方法的unscaledWidth和unscaledHeight屬性。
問題是,爲什麼你需要檢測屏幕尺寸。如果您只是需要使用它們來確定組件的孩子的大小和位置,那麼我相信我上面描述的解決方案是最好的。如果您因其他原因需要此信息,請解釋。
這是一個方式,大小和標籤位置的裏面的updateDisplayList它的容器:
protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
super.updateDisplayList(unscaledwidth, unscaledHeight);
// first position it
// you could also use this.myLabel.move(x,y) method to position the element
this.myLabel.x = 0;
this.myLabel.y = 0;
// then size it
// sizing to 100% height/width of container
this.myLabel.height = unscaledHeight;
this.myLabel.width = unscaledWidth;
// or you could also use setActualSize; which is slightly different than setting height and width
// becaues using setActualSize won't set the explicitHeight/explicitWidth, therefore measure will still
// execute
this.myLabel.setActualSize(unscaledWidth, unscaledHeight)
// or you could set the label to it's measured height and measured width
this.myLabel.height = this.myLabel.getExplicitOrMeasuredHeight();
this.myLabel.width = this.myLabel.getExplicitOrMeasuredWidth();
}
5
在大多數情況下,它是使用更可靠FlexGlobals.topLevelApplication.width
和FlexGlobals.topLevelApplication.height
。
相關問題
- 1. 屏幕尺寸檢測後的Coldfusion
- 2. 檢測物理屏幕尺寸
- 3. 有沒有辦法在MVC3中檢索手機屏幕尺寸
- 4. 屏幕尺寸
- 5. 屏幕尺寸
- 6. 如何檢測手機網頁瀏覽器及其屏幕尺寸
- 7. XLARGE VS sw720dp屏幕尺寸的混亂
- 8. 每個屏幕尺寸手動
- 9. CSS屏幕尺寸
- 10. Android屏幕尺寸
- 11. Android屏幕尺寸
- 12. 安卓相機的屏幕尺寸
- 13. Android:相機的尺寸與屏幕尺寸不匹配
- 14. Javascript自動屏幕尺寸測試
- 15. 如何檢查初始屏幕尺寸
- 16. 如何在uiautomator下獲得android手機屏幕尺寸
- 17. 不同的android手機屏幕尺寸問題
- 18. 哪款Android手機擁有大屏幕尺寸
- 19. 引導下4手機屏幕尺寸卡scrubles
- 20. 如何讓網站適應手機和iPad屏幕的尺寸?
- 21. 只能在手機屏幕尺寸上使用slick.js
- 22. 如何顯示比手機屏幕尺寸大的圖像?
- 23. 如何讓網站適應不同尺寸的手機屏幕?
- 24. Android的 - 設置壁紙,以適應手機屏幕尺寸
- 25. 什麼是使用手機屏幕尺寸的適當方式?
- 26. 比例流星應用程序到手機屏幕尺寸
- 27. Android模擬器沒有顯示全尺寸的手機屏幕
- 28. iPhone 6(Plus)屏幕尺寸
- 29. 侷限於屏幕尺寸
- 30. 屏幕尺寸的UIScrollView
我還不清楚'updateDisplayList()'如何定位組件的子元素。對於多行文本(默認)'標籤',必須設置'width'。在線上的各種教程後,我從舞臺/屏幕寬度--2 *邊距(假設它跨越屏幕的可讀寬度)設置此寬度。 updateDisplayList如何在那裏工作? – ina
我更新了我的答案,提供了關於如何在updateDisplayList中設置組件大小的示例代碼。 – JeffryHouser
我想我還沒有理解的是你如何在運行時調整容器大小?看起來這將是不同的屏幕尺寸。 – ina