Ok, found it.  I can use iv.getDrawable().getIntrinsicWidth() and height.

On Fri, Dec 24, 2010 at 11:55 AM, John Lussmyer <johnlussm...@gmail.com>wrote:

> I'm building some parts of my UI dynamically, and really need to know an
> ImageView's size before it's painted on screen.
> How can I do this?
>
> My code currently does this:
>
>         ImageView iv = new ImageView(this.getApplicationContext());
>         iv.setImageResource(R.drawable.icon);
>         iv.setAdjustViewBounds(true);
>         iv.setScaleType(ImageView.ScaleType.CENTER);
>
>         animView.addView(iv);
>         debugTxt( "w=" + iv.getWidth() + ", h=" + iv.getHeight());
>
> And the debug msg shows the sizes as 0.  When I later use the sizes in my
> calculations, it throws everything off.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to