如何在android中使用setImageURI()?

时间:2022-09-03 23:31:38

I tried

我试过了

imageView=(ImageView)view.findViewById(R.id.imageView);
Uri photoUrl = profile1.getPhotoUrl();
imageView.setImageURI(photoUrl);

But i dont see anything. I am getting url when i am printing it Thanks in advance

但我没有看到任何东西。我在打印时得到的网址提前感谢

2 个解决方案

#1


3  

Try to use picasso for this:

尝试使用毕加索:

 Picasso.with(context)
           .load(url)
           .placeholder(R.drawable.placeholder)
           .resize(imgWidth, imgHeight)
           .centerCrop()
           .into(image);

#2


2  

Try this

尝试这个

Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("YOUR_URL").getContent());
imageView.setImageBitmap(bitmap);

#1


3  

Try to use picasso for this:

尝试使用毕加索:

 Picasso.with(context)
           .load(url)
           .placeholder(R.drawable.placeholder)
           .resize(imgWidth, imgHeight)
           .centerCrop()
           .into(image);

#2


2  

Try this

尝试这个

Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("YOUR_URL").getContent());
imageView.setImageBitmap(bitmap);