Try making these images into 9-patch pngs. Read up on the draw9patch
tool in the android sdk.

You can also leverage the different res folders for different scale
devices (drawable-hdpi, drawable-mdpi, drawable-ldpi)

On Apr 20, 1:09 pm, Dianne Hackborn <[email protected]> wrote:
> The size of app icons is 48x48 dp units.  If you are drawing them at some
> different size, they will be blurry because you are scaling them from their
> designed size.
>
> On Tue, Apr 19, 2011 at 8:59 PM, varinag gold <[email protected]> wrote:
>
> > Hi,
>
> > I am displaying a grid of icons of all the applications on my device
> > and I found after I resize them to be all same width and height they
> > appear on screen some what blurred or foggy .  Also the Icon Text
> > looks blurred . I have put code snippet below that actually resizing
> > the icons.
>
> > Please let me know if I am missing some thing to make them appear
> > sharp on screen.
>
> > Thanks a lot.
> > varinag
> > -------------------------------------------------
>
> >  if (!info.filtered) {
>
> >            int width = 42;
> >            int height= 42;
>
> >            final int iconWidth = icon.getIntrinsicWidth();
> >            final int iconHeight = icon.getIntrinsicHeight();
>
> >            if (icon instanceof PaintDrawable) {
> >                PaintDrawable painter = (PaintDrawable) icon;
> >                painter.setIntrinsicWidth(width);
> >                painter.setIntrinsicHeight(height);
> >            }
>
> >            if (width > 0 && height > 0 && (width < iconWidth ||
> > height < iconHeight)) {
> >                final float ratio = (float) iconWidth / iconHeight;
>
> >                if (iconWidth > iconHeight) {
> >                    height = (int) (width / ratio);
> >                } else if (iconHeight > iconWidth) {
> >                    width = (int) (height * ratio);
> >                }
>
> >                final Bitmap.Config c =
> >                        icon.getOpacity() != PixelFormat.OPAQUE ?
> >                            Bitmap.Config.ARGB_8888 :
> > Bitmap.Config.RGB_565;
> >             //   final Bitmap thumb = Bitmap.createBitmap(80, 80, c);
> >                final Bitmap thumb = Bitmap.createBitmap(42, 42, c);
> >                final Canvas canvas = new Canvas(thumb);
> >                canvas.setDrawFilter(new
> > PaintFlagsDrawFilter(Paint.DITHER_FLAG, 0));
> >                // Copy the old bounds to restore them later
> >                // If we were to do oldBounds = icon.getBounds(),
> >                // the call to setBounds() that follows would
> >                // change the same instance and we would lose the
> >                // old bounds
> >                mOldBounds.set(icon.getBounds());
> >               // icon.setBounds(0, 0, 80, 80);
> >                icon.setBounds(0, 0, width, height);
> >                icon.draw(canvas);
> >                icon.setBounds(mOldBounds);
> >                icon = info.icon = new BitmapDrawable(thumb);
> >                info.filtered = true;
> >            }
> >        }
>
> >        final TextView textView = (TextView)
> > convertView.findViewById(R.id.label);
> >        textView.setCompoundDrawablesWithIntrinsicBounds(null, icon,
> > null, null);
> >        textView.setText(info.title);
>
> >        return convertView;
> >    }
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

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

Reply via email to