views:

329

answers:

1

I've determined an estimate of the size of my Android emulator's screen in pixels, although I think its resolution can be changed to other numbers. Quite frankly though that doesn't eliminate the general problem of not knowing how many pixels on each axis I have to work with on my Android applications in general.

The main problem I'm trying to solve is this: How do I make sure I don't use a faulty resolution on Android applications if I want to keep things' sizes constant (so that if the application screen shrinks, for instances, objects will still show up just as big - there just won't be as many of them being shown) if I wish to do this with a single universal resolution for each program? Failing that, how do I make sure everything's alright if I try to do everything the same way with maybe a few different pre-set resolutions?

Mainly it seems like a relevant question that must be answered before I can come across a complete answer for the general problem is how big can I always make my application in pixels, NOT regarding if and when a user resizes the application's screen to something smaller than the maximum size permitted by the phone and its operating system.

I really want to try to keep this simple. If I were doing this for a modern desktop, for instance, I know that if I design the application with a 800x600 canvas, the user can still shrink the application to the point they're not doing themselves any favors, but at least I can basically count on it working right and not being too big for the monitor or something. Is there such a magic resolution for Android, assuming that I'm designing for API levels 3+ (Android 1.5+)?

Thanks

+1  A: 

Hmm, I suggest you read this: Supporting Multiple Screens. That gives a wealth of information on how to handle different screen sizes. In particular, read about its concept of density independent pixels versus absolute pixels. Density independent pixels are essentially pixel sizes that the system automatically scales for you depending on the screen size you're working on. It considers the 'standard' screen as that of the G1, Hero or similar devices, i.e. 480x320 pixels with a density of 160dpi. If the screen you're working with is bigger than that, i.e. the Droid or Nexus One, it adjusts all density independent pixel sizes by 50%.

Alternatively, if you're really talking about canvases, as in, Canvas for animations etc, you can just call canvas.getWidth() and canvas.getHeight().

Steve H
I'm a tad worried about using methods like those two though. If I use those, I think I basically have to keep stuffs' sizes in proportion to the canvas, which means that when the screen is resized, my sprites are too. Also it's more complex to work with, which is something that I don't really want. But I'll look at that article some. Thanks.
Panzercrisis
My comment about DPs probably wasn't very clear because I didn't explain well enough the problem about screen pixel densities. It's explained in the article as well, but in case you haven't had a chance to read it yet, the problem is that the different devices have different pixels per inch screen densities. So for something to appear the same physical size, e.g. 1/2" by 1/2" on the screen, the actual number of pixels being used has to change in proportion to the screen dpi. That said, having now glanced at your other questions, I'll eventually add more information about canvases.
Steve H