On Oct 6, 10:33 am, Romain Guy <romain...@android.com> wrote:
> Instead of calling setCompoundDrawablesWithIntrinsicBounds(), just use
> setCompoundDrawables() and set your own bounds.
>
Thanks - notice that my post indicated setBounds() was a solution.

To scale and retain the aspect ratio I did the following.  This gets
the job done :-) but is there a simpler method?

static public Drawable scaleDrawable(Drawable drawable, int width, int
height)
{
      int wi = drawable.getIntrinsicWidth();
      int hi = drawable.getIntrinsicHeight();
      int dimDiff = Math.abs(wi - width) - Math.abs(hi - height);
      float scale = (dimDiff > 0) ? width/(float)wi : height/
(float)hi;
      Rect bounds = new Rect(0, 0, (int)(scale*wi), (int)(scale*hi));
      drawable.setBounds(bounds);
      return drawable;
}



-- 
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