How to get correct ImageView width?
<p>I would like to get a ImageView width but all my results don't get me correct values.</p>

<p>I tryed: <code>myImageView.getWidth();</code> but it return 0.</p>

<p>I also tryed: <code>myImageView.getMeasuredWidth();</code> but it return 0 too.</p>

<p>And I tryed: <code>myImageView.getLayoutParams().width;</code> but it return -1.</p>

<p>My ImageView :</p>

<pre><code> &lt;ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/myImageViewId"
        android:src="@drawable/img"/&gt;
</code></pre>

<p>And my activity:</p>

<pre><code>public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myLayout);

    ImageView myImageView;
    myImageView = (ImageView)findViewById(R.id.myImageViewId);

    int width = myImageView.getLayoutParams().width;
    Log.d("Perso","width = "+width);
}
</code></pre>

<p>Do you know why I don't get a correct return ?
Thank's advance.</p>