1. 程式人生 > >Glide 4.x Placeholder(佔位圖)不會被處理成圓角

Glide 4.x Placeholder(佔位圖)不會被處理成圓角

解決這個問提一種方法就是讓UI直接切圓角圖;另一箇中就是通過thumbnail方法對佔位圖再做圓角處理,具體實現如下:


    public static void loadRoundImg(ImageView imageView, String url, @DrawableRes int placeholderId,
                                    @DrawableRes int errorId, float radius) {

        Glide.with(imageView.getContext()).load(url)
                .
apply(new RequestOptions().placeholder(placeholderId).error(errorId).centerCrop() .transform(new GlideRoundTransform(imageView.getContext(), radius))) .thumbnail(loadTransform(imageView.getContext(),placeholderId,radius)) .thumbnail(loadTransform
(imageView.getContext(),errorId,radius)) .into(imageView); } private static RequestBuilder<Drawable> loadTransform(Context context, @DrawableRes int placeholderId, float radius) { return Glide.with(context) .load(placeholderId) .
apply(new RequestOptions().centerCrop() .transform(new GlideRoundTransform(context, radius))); }