ittianyu ittianyu - 5 months ago 35
Android Question

Already resolved

The problem is resolved. Thank you for your help.


In OnCreate() your view has not yet been created as per your xml parameters. So you have to add addOnGlobalLayoutListener() on your view and you will get your dimensions in that listener once view has been created.

iv.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
    System.out.println("imageview width:" + iv.getWidth() + " height:" + iv.getHeight());