flex纵向滚动条出现后,横向滚动条自动出现(转)
2012-06-15 13:38
791 查看
我在写一个module,放了很多组件,发现只要出现纵向滚动条之后,横向的也会出现,怎么也去不掉,苦恼了很久,终于在网上找了解决办法,
为了让更多的朋友看到,便转到自己的博客中
我这篇文章的来源
http://edu.gamfe.com/tutor/d/24844.html
当你把容器的宽度调为100%后 ,verticalScrollbarPolicy 用默认的auto。这是如果你缩放窗口会出现滚动条,但问题这是就出现了,只要出现了垂直滚动条,水平滚动条就是被迫出现。
这是是由于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方法
为了让更多的朋友看到,便转到自己的博客中
我这篇文章的来源
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; }
相关文章推荐
- 在浏览器窗口大小变化时,自动出现或隐藏滚动条,隐藏横向滚动条,仅保留纵向的
- 在浏览器窗口大小变化时,自动出现或隐藏滚动条,隐藏横向滚动条,仅保留纵向的
- flex自适应高度内容高度超出容器高度自动出现滚动条的问题
- extjs 3.4 在IE8下,tabPanel会同时出现纵向、横向滚动条的情况。影响用户体验。
- textarea:文本输入区内实现换行、出现横向(水平)滚动条、自动定位到最底部
- ASPX 控件添加横向和纵向自动扩展滚动条
- ie6框架下,出现横向滚动条bug
- flex 监听Canvas上滚动条的出现或隐藏
- 内容超过div的长度后自动出现滚动条的实现方法
- 让GridView产生纵向横向的滚动条
- iframe在IE6下出现横向滚动条的解决方案
- 如何做到背景铺满屏幕,且不会出现横向滚动条
- 如何使Flex textarea组件滚动条自动滚到最底部
- 页面如何自动出现滚动条(overflow属性用法)
- 怎样使可编辑的DIV固定大小,当内容多时,就自动出现滚动条
- 相对定位的div没有出现纵向滚动条
- 框架页中针对IE6自适应宽度,不出现横向滚动条
- Flex textarea组件滚动条自动滚到最底部
- Flex中如何通过verticalScrollPolicy属性,控制VBox容器内容超过容器大小时滚动条自动显示与否