hi there I have an ImageView
that contains a Drawable
, I want to know the real size of this Drawable
( width and height ) . how can I get the real size please?
I tried that but its not working:
final ImageView img = (ImageView) findViewById(R.id.imagePlan);
img.setImageResource(R.drawable.gratuit);
System.out.println("w=="+img.getDrawable().getIntrinsicWidth()+" h=="+img.getDrawable().getIntrinsicHeight());
thanks
First you have to convert drawable into bitmap then you can get image height and width.
try below code:-
BitmapDrawable bd=(BitmapDrawable) this.getResources().getDrawable(imageID);
double imageHeight = bd.getBitmap().getHeight();
double imageWidth = bd.getBitmap().getWidth();