Amit Kumar
Amit Kumar

Reputation: 454

How to use same of placeholder as Image size using Picasso

I am trying to put a placeholder of same size as Image to be render inside the ImageView using Picasso. Please help me regarding this.

This is what I have done in my code

Transformation blurTransformation = new Transformation() {

        @Override
        public String key() {
            return "blur()";
        }

            @Override
            public Bitmap transform(Bitmap source) {
                // TODO Auto-generated method stub
                Bitmap blurred = Blur.fastblur(mContext,
                        source, 10);
                source.recycle();
                return blurred;
            }
        };
Picasso.with(mContext).load(url).placeholder(R.drawable.placeholder_blur).transform(blurTransformation)
                                .into(Imageview,new Callback() {

                                        @Override
                                        public void onSuccess() {
                                            // TODO Auto-generated method
                                            // stub
                                            Picasso.with(mContext).load(url).placeholder(Imageview.getDrawable()).into(Imageview);
                                        }

                                        @Override
                                        public void onError() {
                                            // TODO Auto-generated method
                                            // stub

                                        }
                                    });

Problem I am facing is I have drawable of size 225 * 225 and for all the size the placeholder image remains same. I want something like facebook having placeholder of same size as the size of image which will load after that.

Upvotes: 2

Views: 1087

Answers (1)

anonymous
anonymous

Reputation: 386

Use Glide library.

Glide.with(_activity)
.load(url)
.placeholder(R.drawable.ic_launcher).override(200, 200)
.error(R.drawable.ic_launcher).centerCrop()
.into(c_holder.img);

Upvotes: 0

Related Questions