I'm running into trouble setting up a flexible layout in an ItemTemplate for my ListView.
I've set up my template similar to as follows:
<ItemTemplate class="flex" name="flexibleTemplate"> <View class="labelWrapper"> <Label class="title" bindId="title" /> <Label class="body" bindId="body" /> </View> </ItemTemplate>with some tss:
".flex": { height: 100 }, ".labelWrapper": { layout: 'vertical' }, ".title": { font: {fontSize: 22}, top: 5 }, ".body": { font: {fontSize: 16}, top: 3, bottom: 5 }The strings that end up being set on the title and body labels are of variable length. I'd like to set it up such that the title label can be either one or two lines in length, and then truncate if it exceeds two lines; the body label would then ideally fill the rest of the view, also truncating as appropriate.
If I were attempting this outside of a ListView, when setting the data, I'd render the title text offscreen and listen once for a postlayout event. If the height exceeded the known height of two lines of text for that label width and font size, I'd explicitly set the height of the title label such that it would truncate; otherwise, I'd leave it be. The body label would then be free to layout vertically below the title label and truncate as appropriate.
Is there a way to do something similar in a ListView? If I try binding a callback to a child view's postlayout event, it doesn't end up getting passed a reference to an item id that I could use to explicitly set a height in the ListDataItem; setting the height of the source object isn't appropriate due to the way ListItems work.
This is in a mobile alloy project I'm testing on my iPod touch running iOS 7.0.4, using the 3.2.0GA SDK