Why is the imageview height wrong? Picture attached..

You must Login before you can answer or comment on any questions.

I select an image and set it to an imageview, everything scales correctly but for some reason the imageview is way taller than it should be (see the red background). How can I get the imageview to fit the image so I dont have all that unneccessary red background?

Top part of image: http://imgur.com/buJ4S

Bottom part of image: http://imgur.com/X4EsQ

Code is just a simple imageview inside a scrollview. Can post if needed. Running latest of everything on iPhone simulator.

1 Answer

Accepted Answer

Ti.UI.createImageView: {
    height:Ti.UI.SIZE,
    ....
};

— answered 7 months ago by Dan Tamas
answer permalink
5 Comments
  • Thanks but I have tried every mixture of the different settings and still no luck. Here is what the picture looks like with the following code :

    postImage = Ti.UI.createImageView({
                    height : Ti.UI.SIZE,
                    image : "http://solaraluminyum.com/img/wp-content/uploads/cool-background-wallpapers_8844_14.jpg",
                    backgroundColor : 'red'
                });
    http://imgur.com/aXRzd

    I realized if I save the file then read the width and height as a blob I can get the real values. I can then calculate the new size and keep aspect ratio and set the backgroundImage property with the new values. Sucks I have to do it this way but I have wasted too much time on the imageview itself already.

    — commented 7 months ago by andrew royce

  • You never said the image is remote. Until the image is downloaded there is no way for the device to know it's dimensions so the behavior is normal I'd say.

    — commented 7 months ago by Dan Tamas

  • The original image was not remote but from the gallery (which was saved off the internet). I changed it just for demonstation purposes so you could easily copy/paste it.

    — commented 7 months ago by andrew royce

  • Show 2 more comments

Your Answer

This question has been locked and cannot accept new answers.