Adobe Flex - 有什么方法可以自动更改字体大小以适合其容器吗?
我在 Flex 中有一个组件,该组件的一部分是标签。有没有办法自动调整字体大小以适合其容器?
I have a component in Flex, and part of that component is a label. Is there a way to automatically adjust the font size to fit into its container?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不会自动(至少据我所知),没有设置某种事件处理程序,并对某些事件的发生采取行动。下面是一个简单的 AIR 应用程序,它演示了一种方法 - 在本例中,调整大小事件会触发标签的 fontSize 更改:
这里,当调整应用程序大小时,标签的 fontStyle 属性将更改为应用程序高度的一半;放大或缩小它,你就会看到它是如何工作的。当然还有其他方法,一如既往,但因为我们处理的是样式而不是可绑定属性,所以很可能需要一些自定义编码。希望有帮助!
Not automatically (at least not that I know of), without setting up some sort of event handler, and taking action on the occurrence of some event. Here's a simple AIR app that demonstrates one approach -- in this case, a resize event triggering a change in the fontSize of a Label:
Here, when the app gets resized, the label's fontStyle property gets changed to one-half the app's height; scale it up and down and you'll see how it works. There are certainly other approaches, as always, but because we're dealing with styles and not bindable properties, a little custom coding is most likely called for. Hope it helps!
如果您指的是单行标签,那么这个组件可能会对您有所帮助。考虑到它只能使其字体变小(作为对容器宽度减小的反应)。
If you mean a single-line label then this is the component that may help you. Consider that it can only make it's font size smaller (as a reaction to container's width reduction).