Flex 中图像列表中的一张图像的纵向和横向方向的一致视图
我正在使用 Adobe Flex 4.5 编写适用于平板电脑的图像查看器应用程序。基本上,我有一个带有自定义项目渲染器的列表,用于渲染列表中的图像。我已将图像尺寸设置为平板设备纵向的宽度/高度 (600x1024)。这样,一次只能看到一张图像。问题是,当设备面向横向时,这种设计显然会搞砸。我的问题是,当方向改变时,如何让它自动更改图像的宽度/高度,以便一次只显示一张图像?或者,有更好的方法来解决这个问题吗?
这是我的列表:
<s:List width="600" height="1024"
id="imageList" dataProvider="{data}" itemRenderer="{inlineRenderer}" click="imageList_clickHandler(event)"
verticalScrollPolicy="off" useVirtualLayout="true">
<s:layout>
<s:HorizontalLayout columnWidth="600"/>
</s:layout>
</s:List>
这是项目渲染器:
<s:Scroller width="600" height="1024">
<s:Group>
<s:Image source="{data.imageurl}" width="600" height="1024"
contentLoader="{FlexGlobals.topLevelApplication.imageCache}"/>
</s:Group> </s:Scroller>
I'm coding a image viewer application for tablets using Adobe Flex 4.5. Basically, I have a list with a custom item renderer that renders the images in the list. I have set up the image size to be the width/height of the tablet device in portrait (600x1024). This way, only one image can be seen at one time. The problem is that when the device orients to landscape, this design obviously screws up. My question is how can I get it to change the width/height of my images automatically when the orientation changes such that only one image is shown at a time? Or, is there a better way of approaching this?
This is my list:
<s:List width="600" height="1024"
id="imageList" dataProvider="{data}" itemRenderer="{inlineRenderer}" click="imageList_clickHandler(event)"
verticalScrollPolicy="off" useVirtualLayout="true">
<s:layout>
<s:HorizontalLayout columnWidth="600"/>
</s:layout>
</s:List>
This is the item renderer:
<s:Scroller width="600" height="1024">
<s:Group>
<s:Image source="{data.imageurl}" width="600" height="1024"
contentLoader="{FlexGlobals.topLevelApplication.imageCache}"/>
</s:Group> </s:Scroller>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是如何创建自动处理方向更改的仅图像项目渲染器的示例:
即使这个渲染器是用 MXML 编写的,它也应该表现得很好,因为它遵循一些简单的优化规则(请参阅 http://flexponential.com/2011/04/20/flex-performance-tips-tricks/),但您需要在应用程序中对其进行测试以确保感觉良好 好的。
一般来说,Adobe 建议通过扩展 LabelItemRenderer 或 IconItemRenderer 在 ActionScript 中编写项目渲染器,以获得最佳性能。如果上面的渲染器对您来说不够快,那么您可能需要查看 https:// /bugs.adobe.com/jira/browse/SDK-30043 有关当前问题的讨论以及使用 IconItemRenderer 执行此操作的解决方法。
Here is an example of how to create an image only item renderer that handles orientation changes automatically:
This renderer should perform pretty well even tho it is written in MXML because it follows some simple optimization rules (see http://flexponential.com/2011/04/20/flex-performance-tips-tricks/), but you'll want to test it in your application to make sure it feels ok.
In general Adobe recommends writing item renderers in ActionScript by extending LabelItemRenderer or IconItemRenderer for best performance. If the renderer above isn't fast enough for you then you might want to check out https://bugs.adobe.com/jira/browse/SDK-30043 for a discussion on the current problem and workaround to doing this with IconItemRenderer.