Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Styling a ListItem created by a template

$
0
0

Hi,

I'm trying to figure out how to style a list item which is created dynamically via a template, contains two labels and the length of each label is also dynamic.

I would like to:

1/ Set the height of the List Item accordingly to the content (auto height)

2/ Set the position of each label in a way that "label2" is always just after "label1", no matter how many lines "label1" have

I tried to google that and read the documentation and couldn't find anything. I think that this is something that everybody needs to achieve when retrieving data from a REST API and creating a dynamic List View.

Here's an example of what I'm trying to achieve

As you can see the title is not always only 2 lines, but for example also 3 lines.

Here's my implementation:

views/listItem.xml

<Alloy>
    <ItemTemplate name="listItem">
        <Label bindId="title"/>
        <Label bindId="value"/>
    </ItemTemplate>
</Alloy>
styles/listItem.tss
'Label': {
    width: Ti.UI.FILL,
    height: Ti.UI.SIZE,
    textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
    color: '#000'
}
So fair I've found out that:

1/ I can set the height of the listItem in the temple by adding the 'height' attribute, but I don't know how to enable the auto-height.

2/ I can set the position of the labels by specifying the 'top' attribute, but as I said before, I need to have it dynamic.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>