I have an imageView and assigning(reteriving URL from server) 10 images to that view in loop. I haven't define any height and width of imageView. The problem is that when page loads some images have whitespaces above&below that image. Why..??
I've never tried an ImageView without a height and width (how are you using it without height and width anyway?).
I suspect that not all your images have the same dimensions. Maybe Titanium is sizing the ImageView based on the size of the first image.
Imagine if the first image was 320x240. Then the next image was 320x220 -- you would have 10 pixels of empty space at the top and bottom.
One other thing: if cross-platform is a concern, you should know that on Android, the ImageView will stretch your images to fit the box, while on iOS, it will proportionally resize the image.
There's not a one-line solution that I can give you that's going to work for you. This is highly dependent on your application and things like this:
- are your images built into the app, or are they coming from a server?
- do the images all have approximately the same aspect ratio?
- do you need this to work on iOS and android?
- what is your UI layout like for the window in question? Is the imageview essentially full-screen or is it a smaller part of the interface?
If you have radically different image aspect ratios, you're going to have to do some dynamic sizing of the imageview to accomodate those sizes.
You may need to look at how you're getting the images to your application, and send width, height information along with your images.
I do that in my app -- I have a scrollableview that contains a series of imageviews. The user can swipe through the images. My app loads its images from a JSON feed, in which I provide the image URL along with the width and height of each image. I use that width and height to compute the aspect ratio, which helps me size my imageview accordingly.
Think you can help? Login to answer this question!