After the flex vertical scroll bar appears, the horizontal scroll bar automatically appears)

Source: Internet
Author: User

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;   } 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.