【发布时间】:2019-04-03 10:34:47
【问题描述】:
我是 android 开发新手,我尝试使用 picasso 和 circularimageview 组合,但问题是,每当我引用不是来自安全 url(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);
}
为了确保它不是圆形图像视图的问题,我也尝试了 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 图像,它就可以正常工作。
【问题讨论】:
-
试试这个 Picasso.with(context).load("chandra.harvard.edu/photo/2018/kes75/…CircleTransform()).into(imgv);
-
如果你不想浪费时间寻找问题的答案,你也可以试试 Glide
-
我使用的是以下版本的毕加索“com.squareup.picasso:picasso:2.71828”,它没有'with'功能
-
滑翔也有同样的问题
-
我用
with函数尝试了您的网址,但没有成功。我使用的是 2.5.2 版