Android Get Width And Height Of Image From Resource

In Android to get the width and height of an image from your res folder do the following:

BitmapDrawable bd = (BitmapDrawable) this.getResources().getDrawable(R.drawable.icon);
int height = bd.getBitmap().getHeight();
int width = bd.getBitmap().getWidth();

If you want the width and height depending the target density you can use the intrinsic values:

BitmapDrawable bd = (BitmapDrawable) this.getResources().getDrawable(R.drawable.icon);
int imageHeight = bd.getIntrinsicHeight();
int imageWidth = bd.getIntrinsicWidth();