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: 
Where you calling `getWidth()` and `getHeight()` on ImageView? If you calling from `onCreate()` in activity, it won't work. You need to wait for activity window to attached and then call `getWidth() and getHeight()` on ImageView. You can try calling `getWidth() and getHeight()` from `onWindowFocusChanged()` method of your activity.

```
@Override
public void onWindowFocusChanged(boolean hasFocus){
    int width=imageView.getWidth();
    int height=imageView.getHeight();
}

```
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();

```