我有一个 32x32 的 ImageView。它基本上是一个精灵。但是当我去放大图像时,它会像这样模糊:
但我希望它像这样在应用程序中扩展:
这是我尝试过的代码,但它不起作用。我希望将最终图像放在 ImageView 上。
@Override
public View getView(int i, View view, ViewGroup viewGroup)
{
View v = view;
ImageView picture;
TextView name;
if(v == null)
{
v = inflater.inflate(R.layout.gridview_item, viewGroup, false);
v.setTag(R.id.picture, v.findViewById(R.id.picture));
v.setTag(R.id.text, v.findViewById(R.id.text));
}
picture = (ImageView)v.getTag(R.id.picture);
name = (TextView)v.getTag(R.id.text);
Item item = (Item)getItem(i);
Options options = new BitmapFactory.Options();
options.inDither = false; //I THOUGHT THAT TURNING THIS TO FALSE WOULD MAKE IT NOT BLUR, BUT IT STILL BLURRED
options.inScaled = false;
Bitmap source = BitmapFactory.decodeResource(getResources(), item.drawableId, options); //THIS IS THE BITMAP. THE RESOURCE IS THE ID OF THE DRAWABLE WHICH IS IN AN ARRAY IN ANOTHER PLACE IN THIS FILE
picture.setImageBitmap(source); //THIS SETS THE IMAGEVIEW AS THE BITMAP DEFINED ABOVE
name.setText(item.name);
return v;
}
private class Item
{
final String name;
final int drawableId;
Item(String name, int drawableId)
{
this.name = name;
this.drawableId = drawableId;
}
}
}
如果你能帮助我,那就太好了!谢谢!