I'm developing an app using the Appcelerator platform and I've run into an issue.
I have a listview with a custom template where I'm populating an ImageView with remote images (lots of different sizes). I'd like them to scale to 100% width and auto height ( Ti.UI.Fill and Ti.UI.SIZE for width and height).
This works if I don't set a height for the image's container, but I'd like all of my ListItems to have the same height and mask any overflow from too tall images.
When I set a fixed height it tries to fit the image in the container, so there's borders on the left/right or top/bottom, depending on the aspect ratio of the image (seems to ignore Ti.UI.Fill).
There's a trick with using a ScrollView as a container and disabling scrolling on that to achieve what I want, but adding a ScrollView inside a Listview crashes the app.
Would this be achievable?
EDIT: Adding some sample code.
This is my Template declaration:
<Templates>
<ItemTemplate name="eventsListTemplate">
<Label bindId="name" id="name" />
<View id="coverContainer">
<ImageView bindId="cover" id="cover" />
<View id="overlay"></View>
</View>
<Label bindId="startTime" id="startTime" />
<Label bindId="place" id="place" />
</ItemTemplate>
</Templates>
This is where I'm populating a listitem with data:
var mapped = _.map(events,function(event){
return {
name : { text : event.name },
cover : { image : (event.cover) ? event.cover.source : ''},
startTime : { text : Alloy.Globals.formatDate(event.startTime) },
place : { text : (event.place) ? event.place.name : event.owner.name },
id : event.id
};
});
And the relevant styles:
"#cover" :{
width: Titanium.UI.FILL,
height : Titanium.UI.SIZE
},
"#coverContainer":{
height: 120
},