I'm no expert but here are some observations:
I tried to call gridView.getHeight() at my onCreate(), in order to use this to set my ImageView dimentions.
but getHeight() return zero. now I know that UI dimentions are set only after onCreate exits.
You can override the GridView class and intercept the dimensions in onDraw by calling native GridView.getHeight() or
whatever, and pass those to a static field in your Activity, or pass a reference to the Activity to your overridden
GridView class. Point is, the dimensions are available by the time doDraw() is called in the GridView.
I tried to set the imageView size with a set of hard coded values, depend of the grid size.
this work nice on my emulator, with a fixed sized screen. if I want to support different screen sizes and resulotions, this is the wrong way to go.
Find a good place to get the dimensions of the device screen and base all your other values on those--They should be available
in your GridView creator or in its doDraw() method. Not sure where the best place to get them is, maybe even onCreate().
Anyway you can then set all of your variables/dimensions scaled to the screen resolution of the device your app is running
on. This assumes that you have setContentView([GridView]) ie your GridView is the activity's top View, so that it fills the
screen and its dimensions are the screen dimensions.