如何强制从子级到父级调整大小
我有一个类似页面的弹性应用程序。 在我的主应用程序中,有一个显示所有页面的支架(画布)。 问题在于,加载到支架内的组件比主应用程序启动时支架内的组件要大。 支架高度设置为 100%,但当我在他体内加载比他自己更大的组件时,他仍然会出现滚动条。
我怎么解决这个问题? 如果它无法解决,如果我使用视图堆栈它会正常工作吗?
--更新---
持有者看起来像这样:
<mx:canvas height="100%">
</canvas>
但应用程序的末尾低了 500 像素,因此画布高度为 500 像素高。 现在,我将一个新子项放入 1000 像素高的支架内。 现在支架高度应为 1000 像素高
I have a page-like flex application. In my main application is a holder (a canvas) that displays all the pages. The problem is that the components that are loaded inside the holder are bigger than the holder is when the main application starts. The holder height is set to 100% but still he gets scrollbars when I load a bigger component inside of him then himself.
How can I solve this problem? And if it isn't solvable would it work correct if I use a viewstack?
--update---
the holder looks like this:
<mx:canvas height="100%">
</canvas>
But the end of the application is 500 pixels lower so canvas height is 500 pixels high. Now I put a new child inside the holder that is 1000 pixels high. Now the holder hight should be 1000 pixels high
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在将组件添加到主画布之前,检查子组件的大小,看看它是否比父组件大。 如果是,那么您可以在对象上使用scaleX和scaleY将其缩小以适合您定义的区域。
您在问题中声明的是任何弹性容器的默认行为...将更大的东西放入其中,您将获得滚动条。 要消除滚动条,请使用:
编辑:
在 tabNavigator 或 viewStack 上使用“resizeToContent”...或者您可以将父容器的宽度绑定到当前子容器的宽度。
Prior to adding the component to the main canvas check the size of the child component to see if its bigger than the parent. If it is then you can use scaleX and scaleY on the object to scale it down to fit in your defined area.
What you declared in your question is the default behavior for any flex container... put larger things in it and you'll get scrollbars. To eliminate the scrollbars use:
Edit:
Use "resizeToContent" on a tabNavigator or viewStack... or you can bind the width of the parent container to the width of the current child.
这是我正在使用的一些代码,用于自动调整画布大小
// 另存为 AutoResizeCanvas.as
// 测试代码,粘贴到项目的主 mxml 中
This is some code I was playing around with for an auto sizing canvas
// save as AutoResizeCanvas.as
// test code, paste into your project's main mxml