Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

createImageView Sizing Issues on Android

Hello, everyone!

I'm working on an Android app in OSX and I've run into a very odd sizing issue.

var win1 = Titanium.UI.createWindow({
    titleImage:'images/appcelerator_small.png',
    backgroundImage:'images/background.png'
});

var logoImage = Titanium.UI.createImageView({
    width: 286,
    height: 169,
    top:30,
    left:30,
    image:'images/title.png'
});

var observe = Titanium.UI.createImageView({
    width: 174,
    height: 174,
    top:325,
    left:44,
    image:'images/observe.png'
});

var review = Titanium.UI.createImageView({
    width: 174,
    height: 174,
    top:325,
    left:262,
    image:'images/review.png'
});

win1.add(logoImage);
win1.add(observe);
win1.add(review);
win1.open({fullscreen:true});

Here's a screenshot of what's going on, as well as a fake screenshot to show you the correct rendering. Can anyone give me a heads up as to what could be going wrong? canScale values don't seem to change anything. The dimensions of each image are correct, so I'm completely lost. I'm using SDK 2.2 with the WVGA800 screen size.

Thank you so much!

— asked August 20th 2010 by Zach Winter
  • android
  • osx
2 Comments
  • I am also having this problem, I am using SDK 2.2 and the HVGA screen size.

    — commented August 20th 2010 by Colton Arabsky
  • Check the latest answer I just posted - hopefully we're having similar issues. In addition, check out this link considering you're using a different screen size.

    — commented August 20th 2010 by Zach Winter

2 Answers

  • Image scaling on Android doesn't currently work. See Ticket #32238. Scheduled for a fix in the 1.5.0 release.

    — answered August 20th 2010 by Matt Collinge
    permalink
    1 Comment
    • The problem is that the images are being displayed much larger than their pixel resolution, not that they won't scale down to the size I've defined. Do you know of any other tickets that deal with this issue? Thanks!

      — commented August 20th 2010 by Zach Winter
  • I just discovered that I've been working in pixels when I should have been working in density-independent pixels, which equal 1.5 physical pixels on the HTC Incredible's WVGA800 screen. Tacking on /1.5 to each of my width and height values fixed the problem completely.

    — answered August 20th 2010 by Zach Winter
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.