flex縱向捲軸出現後,橫向捲軸自動出現)

來源:互聯網
上載者:User

我在寫一個module,放了很多組件,發現只要出現縱向捲軸之後,橫向的也會出現,怎麼也去不掉,苦惱了很久,終於在網上找瞭解決辦法,

為了讓更多的朋友看到,便轉到自己的部落格中

我這篇文章的來源

http://edu.gamfe.com/tutor/d/24844.html

當你把容器的寬度調為100%後 ,verticalScrollbarPolicy 用預設的auto。這是如果你縮放視窗會出現捲軸,但問題這是就出現了,只要出現了垂直捲軸,水平捲軸就是被迫出現。

<?xml version="1.0" encoding="utf-8"?>  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">      <mx:Canvas width="100%" height="700"/>  </mx:Application>  


這是是由於flex在計算前面的百分比時,把垂直捲軸的寬度也算上了,我一開始以為是flex的bug。使其他的官方文檔中寫了一句很華麗的話。


"Flex considers scroll bars in its sizing calculations only if you explicitly set the scroll policy to ScrollPolicy.ON. So, if you use an auto scroll policy (the default), the scroll bar overlaps the buttons. To prevent this behavior, you can set the height
property for the HBox container or allow the HBox container to resize by setting a percentage-based width. Remember that changing the height of the HBox container causes other components in your application to move and resize according to their own sizing
rules."


-- From Sizing Components in the Flex 3 help, under "Using Scroll bars"



就這樣迴避了這個問題。但有個辦法你可以解決這個問題,重載validateSize方法

// In your Application ,module or wherever you need this workaround.   override public function validateSize(recursive:Boolean = false):void {       super.validateSize(recursive);       if (!initialized) return;       if (height < measuredHeight) verticalScrollPolicy = ScrollPolicy.ON;       else verticalScrollPolicy = ScrollPolicy.OFF;   } 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.