我想从互联网上加载图标。我是这样做的:
Drawable drawable = null;
try {
InputStream is = (InputStream) new URL(xml.getBIcon())
.getContent();
Drawable d = Drawable.createFromStream(is, "src name");
drawable = d;
} catch (Exception e) {
System.out.println("Exc=" + e);
}
和
final AlertDialog alertDialog = new AlertDialog.Builder(
context).create();
alertDialog.setTitle(title);
alertDialog.setMessage(text);
alertDialog.setButton("Install",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
String url = link;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
context.startActivity(i);
}
});
alertDialog.setIcon(drawable);
alertDialog.show();
}
不幸的是,图标比它应该低两倍。当它在res文件夹中时,它的大小正确。这是什么原因?