I've found the solution and in case you guys are interested the
following code will do the work for icon resize.
Regards,
argongold
----------------------
public Drawable scaleIcon(Drawable mIcon){
int width = mIcon.getMinimumWidth();
int height = mIcon.getMinimumHeight();
int newWidth = 42;
int newHeight = 42;
// calculate the scale to apply
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// createa matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
Bitmap bmp = ((BitmapDrawable) mIcon).getBitmap();
Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, width,
height, matrix, true);
// make a Drawable from Bitmap to allow to set the BitMap
// to the ImageView, ImageButton or what ever
BitmapDrawable newIcon = new BitmapDrawable(resizedBitmap);
return newIcon;
}
On Feb 28, 2:26 pm, argongold <argongol...@gmail.com> wrote:
> Hello,
>
> I am working on an android application for which I need to get
> specific size of icons as I am displaying on smaller scale.
> Is there a straight forward way to resize/scale an icon to achieve its
> specific size.
>
> Kind regards,
> argongold
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment