【问题标题】:Set an ImageView from photo url从照片 url 设置 ImageView
【发布时间】:2016-05-26 16:41:10
【问题描述】:

如何将图像从 URL 设置为 ImageView

使用 Firebase 身份验证,我得到登录用户的照片 URL:

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

【问题讨论】:

    标签: android imageview uri firebase-authentication


    【解决方案1】:

    您可以使用 Picasso Library 在 ImageView 中显示图像。 您只需将 url、uri 或资源通过图像视图传递给 Picasso。

    喜欢

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

    要使用毕加索,你需要在 Gradle 中添加以下内容

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

    阅读http://square.github.io/picasso/上的文档

    还有其他库可以在 ImageView 中显示图像。 比如FrescoGlideUniversal Image Loader

    【讨论】:

    • 我使用 Picasso,因为它很容易实现 - 一旦 Gradle 同步,它实际上可以像 1 行代码一样简单。这就是我喜欢的那种图书馆!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    相关资源
    最近更新 更多