Set an ImageView from photo url

北慕城南 提交于 2019-12-02 02:45:09

问题


How can I set an image to a ImageView from a URL?

Using Firebase authentication, I get the photo URL of the signed in user:

Uri uri = firebaseUser.getProviderData().get(0).getPhotoUrl();

回答1:


You can use Picasso Library to show images in ImageView. You just need to pass the url, uri or resource to Picasso with image view.

like

Picasso.with(this).load(/* url of image */).into(/*your imageview id*/);

To use the picasso you need to add the following in Gradle

compile 'com.squareup.picasso:picasso:2.5.2'

Read the documentation on http://square.github.io/picasso/

Also There are other libraries to display image in ImageView. Like Fresco, Glide, Universal Image Loader etc



来源:https://stackoverflow.com/questions/37466644/set-an-imageview-from-photo-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!