Question: In my code I have an `Image View` in my XML layout and I keep changing the source image for this in my code. Now I want to know the width and height of the generated image each time.

I tried using `getWidth()`, `getHeight(),` `getMeasuredWidth(),` and `getMeasuredHeight()`, but they all return 0.

How can I get this?

Answer: 
try this

```
 ImageView iv=(ImageView)findViewById(R.id.image);
 ViewTreeObserver vto = iv.getViewTreeObserver();
    vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        public boolean onPreDraw() {
           finalHeight = iv.getMeasuredHeight();
           finalWidth = iv.getMeasuredWidth();
           Log.e("hilength","Height: " + finalHeight + " Width: " + finalWidth);
            return true;
        }
    });

```
First you have to convert the image to mutablebitmap and the try to get the width and height of the image and mostly this will solve your issue..

```
    Bitmap Rbitmap = Bitmap.createBitmap(bitmap).copy(
                    Config.ARGB_4444, true);

Rbitmap.getWidth();
Rbitmap.getheight();

```