Images shifting with auto height or width
Ok, the whole url: to image: deprecation really screwed me over and I can't get back on track.
So, I've got an image I want to display in the top left corner (top: 10, left: 10). I've got it at set width and I want it to calculate the height automatically (and shrink it to fit like it use to). However, when it resizes the image it jumps from where it's supposed to be and shifts down like 100px (out of the parent view I might add)
var houseIMG = Ti.UI.createImageView({
image: 'http://www.123.com/image.jpg',
top: 5,
left: 5,
width: 130,
height: 'auto'
});
head.add(houseIMG);
4 Answers
-
If anyone else has the same issue: For me it worked to fix the image height, it will not be distorted. I.e.:
var imageView = Titanium.UI.createImageView({ image: someurl, width: 100, height: 100, top: 10, left: 10 });
Even if the image is not square, it will center itself in the specified area.
-
J P: I'm having the exact same problem. Seems like this has not been fixed.=(
-
I also am experiencing this same bug. I am specifying an image as follows:
var image = Ti.UI.createImageView({ image : imageUrl, width : '320', height: 'auto', clickName : 'photo' });
The image is properly resized, but the height of the imageview remains the height of the original image size, thus there is alot of white space above and below the image.
-
I'm not sure if this is what you're experiencing, but…
In my current version 1.5, if you're resizing an image when putting it in an imageView (using width: x, height: 'auto'), the original height is assigned to the view, even though the image appears to be resized.
For an example image 719x758:
var image = Titanium.UI.createImageView({ image: "example.jpg", left: 0, top: 0, width: 50, height: 'auto' }); Titanium.API.debug("Resized width = " + image.size.width); // [DEBUG] Resized width = 50 Titanium.API.debug("Resized height = " + image.size.height); // [DEBUG] Resized height = 758
Titanium SDK 1.5, iPhone SDK 4.2
I guess this is a bug :(