Yesterday I was working to scaledown the dimension of an image for my Application in iPhone and Android using Titanium. Without any effort I could achieve it in iPhone, but when I tried the same in Android I did not get the result I was expecting. The image was always taking up its original space without getting scaled down.

Finally I got to the solution. In iPhone implementation of Titanium, by default the image is set to be scalable and for Android the it is not scalable.

Setting canScale property to true and enableZoomControls to false did the trick for me.
By Default, enableZoomControls is true in Android. That is why we have set it to false.

Here is the code. Grab it.


var imageView = Ti.UI.createImageView({
    width: 40,
    height: 40,
    canScale:true,
    enableZoomControls:false,
    image: '/logo.png'
});

Advertisements