Layout problems

  • Replies:4
  • OpenNot stickiedUnanswered

May 10, 2010 6:41:55 PM via Website

I created a lovely wee app, that looks great on the G1, but having just seen it on the HTC Desire, I'm now in a state of shock. The layout has gone all over the place and it's even wrapped the text on one of my buttons despite there being planty of space on the page! Anyone else encountered problems like this?

Best wishes
Iain

May 10, 2010 7:20:42 PM via Website

Are the dimensions of certain aspects of your app set to run on # of pixels and other sections on a percentage of the screen size? Or is that not possible? I'm not well versed in app making, but I know I had troubles with that when designing web pages.

— modified on May 10, 2010 7:22:00 PM

May 11, 2010 5:59:57 AM via Website

Hi Iaindownie,

It may be because the desire is a high density or greater pixels per inch, device. Check this page from the android developers guide on developing for different screen sizes: http://developer.android.com/guide/practices/screens_support.html

The part there that talks about dips is important, I've pasted it below.

Density-independent pixel (dip)
A virtual pixel unit that applications can use in defining their UI, to express layout dimensions or position in a density-independent way.
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the platform transparently handles any scaling of the dip units needed, based on the actual density of the screen in use. The conversion of dip units to screen pixels is simple: pixels = dips * (density / 160). For example, on 240 dpi screen, 1 dip would equal 1.5 physical pixels. Using dip units to define your application's UI is highly recommended, as a way of ensuring proper display of your UI on different screens.
Range of Screens Supported

May 11, 2010 10:04:58 AM via Website

Thanks both for your comments. I'll chase up the dip approach and review the screenshot advice on developers guide. Good place to start. What a pain, but it needs doing.

May 27, 2010 6:08:58 PM via Website

Hi again,
I had a play with the dip values. I created two test virtual devices in Eclipse, one based on the G1 screen size, and one on the Desire screen size. I tested on both, and they looked great - I was surprised that just changing px to dip would work, and quite right. It still looks terrible on the Desire screen, and I haven't my G1 any more so assume that it's OK on that.
Have I missed something? Anyone with any good experience of setting up these virtual devices based on diff phones? The desire is only WVGA (480x800), 3.3"-4.0" diagonal, so comes under a 'normal screen' on the Google API help I'm using. I realise I am not the best developer in the world (far, far from it), but this doesn't seem like an intuitive system for beginners to get their head around....
Iain