I want an image to occupy for each screen resolution the same space for all resolutions. E.g.: I want an image to always be 1/5 of the screen.
I have the following code:
private boolean CheckHeaderSize()
{
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
maximumHeaderSize = size.y / 5;
BitmapFactory.Options dimensions = new BitmapFactory.Options();
dimensions.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.drawable.header, dimensions);
headerSize = dimensions.outHeight;
if (dimensions.outHeight > maximumHeaderSize)
return false;
return true;
}
But in different screen resolutions is giving me different values... Obviously. I've been googling and I can't find the correct solution...
How can I make the image alwas use the same space and doesn't matter screen resolution?