I'm finding Android's choice of image resources for buttons based on screen-density to be unhelpful.
I'm developing an app for kids, and so I want it to have nice big obvious buttons, but at the same time I have to limit myself to the available screen real-estate.
Essentially I want to use image sizes appropriate to the screen-size that I have, not to it's density.
For example, lets say I want to fit 5 buttons down the side of the screen in landscape mode. I'd like to do something like this..
- Get the height of the screen in PIXELS.
- Calculate the height of each button (hButton), allowing for some space in between.
- Load the appropriate image resource. I.e. the smallest one that is at least hButton pixels.
- Scale the image to be hButton pixels high.
Something like that.
Does Android have a nice way of doing this, or do I have to code that myself? How do I access the appropriate images? (most of my buttons use two images - Up and Down)
Thanks
EDIT:
It seems I wasn't clear enough in my question. I don't need to know how to lay out buttons, and I have a good understanding of how Android chooses images based on density - THAT is the problem.
Consider these two devices -
1/ Galaxy I9000 phone - screen size 4" HDPI
2/ Samsung Tab 3 tablet - screen size 7" HDPI
Because both have the same screen density, both will show images at the same physical size. An icon that is 1" square on one will be 1" square on the other. THAT is the problem. I want the buttons to be proportional to the screen size.
I could try using size specific resources (e.g. drawable-small), but then there will be issues between small devices of different densities, which would then mean creating lots more directories, which seems like a bad idea.
I leaning towards putting a variety of sizes in the no-dpi directory, and then loading as needed.