@BindingAdapter({"profileImage"}) public static void loadImage(ImageView view, String imageUrl) { Glide.with(view.getContext()) .load(imageUrl) .apply(RequestOptions.circleCropTransform()) .into(view); // If you consider Picasso, follow the below // Picasso.with(view.getContext()).load(imageUrl).placeholder(R.drawable.placeholder).into(view); }
@Override public void loadUserPic(String picUrl) { if (picUrl == null) { return; } Glide.with(getApplicationContext()).load(picUrl).apply(RequestOptions.circleCropTransform()).into(mImgUserPic); }
private void updateUI(@Nullable User user){ if (user != null){ Glide.with(this).load(user.getAvatar_url()).apply(RequestOptions.circleCropTransform()).into(imageView); this.username.setText(user.getName()); this.company.setText(user.getCompany()); this.website.setText(user.getBlog()); } } }
/** * 加载圆形 * * @param url url * @param imageView imageView */ public static void loadImageCircle(ImageView imageView, String url) { if (TextUtils.isEmpty(url)) { return; } Glide.with(imageView.getContext()) .load(url) .apply(RequestOptions.circleCropTransform() .placeholder(R.drawable.ic_loading_image) .error(new ColorDrawable(Color.WHITE)) .fallback(new ColorDrawable(Color.RED))) .into(imageView); }
Glide.with(this) .load(authorPhoto) .apply(RequestOptions.circleCropTransform().placeholder(R.drawable.avatar_small)) .into(authorPhotoView);
ivImage.setLayoutParams(lp); String imageUrl = SPUtil.getStringDefault(WebViewActivity.ARTICLE_IMAGE_URL, ""); RequestOptions requestOptions = RequestOptions.circleCropTransform(); requestOptions.placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round); Glide.with(context).load(imageUrl).apply(requestOptions).into(ivImage);
.apply(RequestOptions.circleCropTransform().placeholder(R.drawable.avatar_small)) .into(holder.authorPhoto);