简体   繁体   English

Flex DataGroup设置项目渲染器的高度

[英]Flex DataGroup setting the height of the item renderer

I've been playing around with renderers the last few days for a mobile application. 最近几天,我一直在与渲染器一起玩移动应用程序。 I'm creating a gridlike renderer that has columns that is light weight for a mobile app. 我正在创建一个网格状的渲染器,其中的列对于移动应用程序而言是轻量级的。 It is a bit of a poor man's datagrid. 这有点像一个穷人的数据网格。 The layout is fine. 布局很好。 The question I have is controlling the height of each row in the list. 我的问题是控制列表中每一行的高度。

When measure() is called, I set the measuredHeight to: 调用measure()时,我将measuredHeight设置为:

  measuredHeight = getElementPreferredHeight(ld) + verticalPadding; 

where vertical padding is: 垂直填充为:

  var verticalPadding:Number = getStyle("paddingTop") + getStyle("paddingBottom");

When I debug on the desktop, the measuredHeight is set to 12 and on the device (Motorola Atrix), it is set to 12. 当我在桌面上调试时,measuredHeight设置为12,在设备(Motorola Atrix)上,将其设置为12。

But when layoutContents is called, the unscaledHeight is a number much larger than my measuredHeight value (44 on the device, 66 when running on the desktop), resulting in more vertical whitespace surrounding each item than I care to have. 但是,当调用layoutContents时,unscaledHeight比我的测得的Height值大得多(在设备上为44,在桌面上运行时为66),导致每个项目周围的垂直空白超出我的期望。

I'm certain I'm missing something but how do I control that row height? 我确定我缺少了什么,但是如何控制行高呢? I happen to be using a Datagroup for this particular example but in some playing around I did with just a simple list, I had the same issue. 在这个特定的示例中,我碰巧使用了一个数据组,但是在一些简单的列表中,我遇到了同样的问题。 Somewhere the system is overriding my measuredHeight with some other value. 系统在某个地方用其他一些值覆盖了我的measuredHeight。

Any ideas? 有任何想法吗?

Randy 兰迪

Are your code segments part of the renderer or part of the DataGroup? 您的代码段是渲染器的一部分还是数据组的一部分? Or somewhere else? 或者别的地方?

In Flex, a parent is always responsible for sizing it's children. 在Flex中,父母始终负责为其子女定尺寸。 In the case of renderers, the DataGroup is the parent and the renderer instances are the children. 对于渲染器,DataGroup是父级,渲染器实例是子级。 So, no matter what sizing you specify in the itemRenderer, it may not be used. 因此,无论您在itemRenderer中指定什么尺寸,都可能无法使用它。 measuredHeight and measuredWidth are just suggestions which the parent container can choose to ignore--or not--based on it's implementation. measuredHeight和measuredWidth只是父容器可以根据其实现选择忽略(或不忽略)的建议。

You can use typicalItem to help calculate the default row sizing. 您可以使用TypicalItem来帮助计算默认的行大小。

You could also create a custom layout class to size and position your children. 您还可以创建一个自定义布局类来确定孩子的大小和位置。

When using a VerticalLayout , the width is fixed unless you set variableRowHeight to true. 使用VerticalLayout时 ,除非将variableRowHeight设置为true,否则宽度是固定的。 More Info in the docs . 文档中的更多信息 You can also set the rowHeight property on the layout class to specify the height for all rows. 您还可以在布局类上设置rowHeight属性,以指定所有行的高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM