Android Picasso,无法显示带有HTTP URL的图像

时间:2018-10-30 11:32:31

标签: android android-studio

我是Android开发的新手,我尝试使用毕加索和CircularImageView组合,问题是,每当我引用的不是来自安全网址(HTTP)的图像时,组合都无法工作

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_userdataupdate);
    getSupportActionBar().setBackgroundDrawable(
            getResources().getDrawable(R.drawable.actionbargradient));

    CircularImageView civ = findViewById(R.id.profileImg);
    Picasso.get().load("http://chandra.harvard.edu/photo/2018/kes75/kes75_w11.jpg").transform(new CircleTransform()).into(civ);
    ImageView imgv = findViewById(R.id.imageView2);
    Picasso.get().load("http://chandra.harvard.edu/photo/2018/kes75/kes75_w11.jpg").transform(new CircleTransform()).into(imgv);

}

为了确保它与circularimageview没问题,我也尝试过imageview。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/trialimage"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".userdataupdate">


<com.mikhaellopez.circularimageview.CircularImageView
    android:id="@+id/profileImg"
    android:layout_width="157dp"
    android:layout_height="144dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="122dp"
    app:civ_border_color="#EEEEEE"
    app:civ_border_width="4dp"
    app:civ_shadow="true"
    app:civ_shadow_color="#8BC34A"
    app:civ_shadow_radius="10" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="139dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="124dp"
    tools:srcCompat="@tools:sample/avatars[1]" />

如果我将src替换为任何https图像,它就可以正常工作。

1 个答案:

答案 0 :(得分:1)

嗨,伙计们感谢您的快速帮助和解答,发现问题与这篇文章有关

How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

现在可以正常工作了。

谢谢