I am writing a module and put a lot of components. I found that as long as the vertical scroll bar appears, the horizontal scroll bar will also appear. How can I not get rid of it? I 've been worried for a long time, finally, I found a solution on the Internet,
In order to let more friends see it, they will go to their blog
Source of my article
Http://edu.gamfe.com/tutor/d/24844.html
When you adjust the container width to 100%, verticalscrollbarpolicy uses the default auto. This is if you zoom in the window, there will be a scroll bar, but this is a problem, as long as there is a vertical scroll bar, the horizontal scroll bar is forced to appear.
<?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>
This is because flex calculates the percentage before and calculates the width of the vertical scroll bar. I initially thought it was a flex bug. In other official documents, I wrote a very gorgeous sentence.
"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"
This avoids this problem. But there is a way you can solve this problem. Reload the validatesize method.
// 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; }