【发布时间】:2018-03-02 15:04:34
【问题描述】:
我想从 web url 加载 profiler 图片图像,并从资源中使用 Picasso 库使其循环。我正在这样做,
dependencies {
compile 'com.squareup.picasso:picasso:2.4.0'
}
从资源中加载图片 (R.drawable.profile_sample),
Picasso.with(getApplicationContext()).load(R.drawable.profile_sample).placeholder(setCircularImage(R.drawable.profile_sample)).into(imageView_ProfilePic);
同样来自网址,
Picasso.with(getApplicationContext()).load("http://shidhints.com").placeholder(setCircularImage(R.drawable.profile_sample)).into(imageView_ProfilePic);
我还使用 setCircularImage() 将图像从资源变为圆形。
private RoundedBitmapDrawable setCircularImage(int id) {
Resources res = getApplicationContext().getResources();
Bitmap src = BitmapFactory.decodeResource(res, id);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(res, src);
roundedBitmapDrawable.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f);
return roundedBitmapDrawable;
}
【问题讨论】:
-
嘿伙计使用圆形图像视图库github.com/hdodenhof/CircleImageView 并使用毕加索加载它。
标签: android imageview transform picasso