How to resize ImageView placeholder with picasso - android

Picasso allows me to resize an image. Is there a mechanism for resizing the placeholder? The following is not sufficient. What am I missing?
Picasso.with(mContext).load(url).placeholder(R.drawable.imageview_holder).resize(200, 200).into(imageview);

What I found that works for me is to resize the placeholder (and error image) directly with the ImageView using android:scaleType="fitCenter" in the XML. Then I can still use Picasso to resize and center the downloaded image.

Related

How to preload imageView's height and width attribute?

When using a recycleView with many images, Glide takes a while to load the image for the first time, how can I preload the image's height and width by setting the imageView to that size before using glide to load it in?
Glide.with(mContext)
.load(link)
.apply(RequestOptions.centerInsideTransform())
.into(holder.vhImageView);
Reddit also does it this way
Glide may have an equivalent method, but I use Picasso, and you can set a .placeHolder(R.drawable.placeholder) image that will be in place until the image actually loads.
You could assign holder.vhImageView a default image in xml that should also work as a placeholder as long as Glide doesn't clear it as it's loading the new image?
You could set a minHeight on the holder.vhImageView in XML but that can cause problems if the views loaded end up being shorter than that.

Display images with proper dimensions before loading using glide and recyclerview

How do I display images in a facebook like feed? So far I've been using match_parent for width and wrap_content or fixed height. This works well but I need to show proper blank space for image feeds while it's getting lazy loaded. Like how do I set the dimensions properly for the image before loading it from the internet.
I think about getting the aspect ratio or the image dimensions itself via the api. Is it the only correct way or is there some other better way to achieve it using glide or any image loading library?
If you are using glide, you can set a place holder image or drawable with the dimensions you need while the real image is being downloaded.
Glide
.with(context)
.load(UsageExampleListViewAdapter.eatFoodyImages[0])
.placeholder(R.mipmap.ic_launcher) // can also be a drawable
.into(imageViewPlaceholder);

Picasso Library: Does Fit() function resize the image?

I am currently using the Picasso to load the image file to image view on android. I tried to have an image resized then using fit to fit on the imageView. The fit cannot be used with resize.
Picasso.With().Load().Resize().Fit().Into()
Does the fit function will resize the image.
From the Document of Picasso
Attempt to resize the image to fit exactly into the target ImageView's
bounds. This will result in delayed execution of the request until the
ImageView has been laid out.
So i think the fit function will resize the image.

How can I set Picasso placeholder scaleType?

I've problem with placeholder images in Picasso. I use scaleType fitXY on one of my imageViews, but I don't really wanna scale my placeholder, is there a way that I can set different scaleType for my placeholder and another one for loaded image?
Use Fresco lib open source library by Facebook, Using this library You can set different scale type to placeholder image and actual image use this link for reference http://frescolib.org/

loading image into android imageView with ion returns a blurry result

I'm trying to load an image from filesystem into an imageView with the ion library.
When I'm using the following code:
Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.load(uri);
it (sometimes) results in a kind of blurry image.
When not using ion like the following the pictures appear sharply:
imageView.setImageBitmap(BitmapFactory.decodeFile(uri.toString()));
Is there a standard compression coming with ion that I can disable?
Strangely not every picture is blurry when using ion, e.g. I have two identical images, only with another name. When I load them into the imageView with ion one is blurry, one is not.
Any help or tips are appreciated!
Ion tries to load the image to fit the bounds of the ImageView. So make sure your ImageView is sized properly in your layout. Alternatively, if you use adjustViewBounds=true to indicate the ImageView is adjusted by the image contents, it won't do that. Or alternatively smartsize(false).
Try this,
Ion.with(context)
.load(url)
.withBitmap()
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.intoImageView(imageView);

Categories

Resources