0

I have set width attribute of the imageView. But it is not taking up the width. It is not the aspect ratio thing. It is something else:

// Create an ImageView.
var content = Ti.UI.createView(
{
    width : '100%',
    height : '90%',
    bottom : '0%',
});

// Create an ImageView.
var dialerImage = Ti.UI.createImageView(
{
    image: '/images/dial.png',
    width : '98%',
    center : '51%'
});


content.add(dialerImage);

But the image never takes that width, it only takes somewhere near 60% of width. I have tried a lot of things. i.e: setting both width and height, setting height only, setting the width and/or height to Ti.UI.FILL, but to no avail.

Output with the above code: enter image description here

I am using Nexus 4. Please also note that if I edit the image and scale it, then it takes more width.

Aqeel Ashiq
  • 1,988
  • 5
  • 24
  • 57

1 Answers1

0

Apparently, the imageView does not take percentage in width or height attributes. I'l have to give the width in dp.

Calculate width in dps from Titanium.Platform.displayCaps.platformWidth

var widthDps = ( Math.ceil( 0.98 * Titanium.Platform.displayCaps.platformWidth)) ;

// Create an ImageView.
var dialerImage = Ti.UI.createImageView(
{
    image: '/images/dial.png',
    width : widthDps,
    left: 4
});
Aqeel Ashiq
  • 1,988
  • 5
  • 24
  • 57