我使用了以下代码,能够获取图像,但是当我尝试将其放在布局背景(线性布局)上时,图像质量会降低并且显示图像模糊。
URL img_value = null;
try {
img_value = new URL("http://graph.facebook.com/"+userId+"/picture?type=large");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bitmap mIcon1 = null;
try {
BitmapFactory.Options opt=new BitmapFactory.Options();
opt.inSampleSize=1;
// mIcon1 = BitmapFactory.decodeFile(pathoffile,opt);
mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream(),null,opt);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ll=(LinearLayout) findViewById(R.id.ll);
BitmapDrawable background = new BitmapDrawable(mIcon1);
ll.setBackgroundDrawable(background);