Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

[iOS] ImageView size keeping aspect ratio

$
0
0

Hi!

I'm currently having a problem in an app I'm developing for both android and iOS. The issue is related to how the imageview size is defined in the different platforms. The aspect of the picture is rectangular, and in Android, the imageview is created so it keeps the aspect ratio, and the ImageView wraps the picture correctly.

In iOS I had to change the height to a value (25% in my case does fine) which creates the imageview with the correct height and keeping aspect ratio. The thing is that the ImageView is not wrapping just the image, but also some free space to the sides (the image is in the center of the ImageView). As I want that imageview to be clickable, its not expected to occupy more than what the image shows so the eventlistener for click doesn't fire when touching that freespace taken by the ImageView.

To add information, I have these ImageViews into a View which is also rectangular, but I guess that shouldn't matter.

Any ideas why is that I'm getting different behaviours? I want the imageview to just wrap the image with no free space taken.

I create the imageview like this in Android:

var iconoGaleria = Ti.UI.createImageView({
        height: Ti.UI.SIZE,
        width: Ti.UI.SIZE,
        center:{x:"50%",y:"50%"},
        image: "/images/galery.png",
        opacity: 0
   });
in iOS
var iconoGaleria = Ti.UI.createImageView({
        height: "25%",
        width: Ti.UI.SIZE,
        center:{x:"50%",y:"50%"},
        image: "/images/galery.png",
        opacity: 0
   });
Thanks!

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>