Glide - Round image without circle crop - android

I'm using this code to show profile image:
Glide.with(getContext()).load(url)
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.circleCrop()
.into(my_profile_image);
But circleCrop() is cropping the image too much. So is there another way to round an image without too much cropping? I research it but I couldn't find another method.

Glide.with(getContext()).load(url)
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.apply(RequestOptions.bitmapTransform(new RoundedCorners(10))) // round
.into(my_profile_image);

How about this?
Glide.with(getContext()).load(url)
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.apply(RequestOptions.circleCropTransform())
.into(my_profile_image);

Related

Images are blurry when rotate the screen android device with Glide

I use glide to load the drawable image in the adapter (the error occurred with the image not located in recyclerview):
Glide.with (holder.ivPreview) .load (mThemeDrawableIds.get (position)).into (holder.ivPreview)
When recording mThemeDrawableIds will be reloaded and notify again. However, the image is blurred compared to the original image.
I tried clearing the cache but the result is still the same.
It might help to also add android:adjustViewBounds="true" to your ImageView in XML.
Also try this code :
Glide.with(imageView).load(mThemeDrawableIds.get (position))
.apply(new RequestOptions()
.fitCenter()
.format(DecodeFormat.PREFER_ARGB_8888)
.override(Target.SIZE_ORIGINAL))
.into(holder.ivPreview);

Image not properly loaded in PolygonImageView using Glide

I am trying to load the image in polygon ImageView using glide library here is the code
GlideApp.with(Activity.this)
.load(path)
.placeholder(R.drawable.user_avatar)
.into(polygonImageView);
When i using this code result is in below image (the image is cut from right and bottom)
But i want this as result
For Polygon ImageView using third party library Click Here to Check Library
Any Help from you will be appreciated.Thanks
I am Refered That PolyGon Imageview Library But Issue was not There.
Just Use This Code It ll be Works Like a Charm
RequestOptions options = new RequestOptions();
options.centerCrop();
Glide.with(this)
.load("your URL")
.apply(options)
.into((ImageView) findViewById(R.id.imageview));

android glide into(Target) OOM

I am using Glide frame to load a picture, I want to set the height and the width of it, and I know what is the width I want, but how can I set the height of it.
what I have tried is blow,and I got an error of OOM. waiting for help, thanks.
if you want change size
Glide
.with(context)
.load(UsageExampleListViewAdapter.eatFoodyImages[0])
.override(600, 200) // resizes the image to these dimensions (in pixel). does not respect aspect ratio
.into(imageViewResize);
Reference
Using override method of glide you can set the dimension of image in pixels.
Glide
.with(context)
.load(url)
.override(50 , 50)
.into(imageview);

Picasso - how to resize placeholder

I'm using a 128x128 circular image, animated by a drawable as a placeholder in Picasso.
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/loading_circle"
android:pivotX="50%"
android:pivotY="50%" />
And this is how my Java code implements it:
Picasso.with(context)
.load(message.getMediaUrl())
.config(Bitmap.Config.ARGB_4444)
.resize(w, h)
.onlyScaleDown()
.centerCrop()
.placeholder(R.drawable.progresscircle)
.into(messageImage);
Note that the image sizing parameters above are required by the final image that is loaded into my chat adapter's imageview.
The problem is, Picasso is blowing up and cropping the placeholder like this:
How can I set separate parameters for the placeholder to be suitably sized? Also, what exact parameters would be helpful?
in XML where you set ImageView add.
android:scaleType="centerCrop"
It may work. you can set fitXY instead of centerCrop if it is not working.
As mentioned here,
Inside your imageviews xml set android:scaleType="centerInside"
Then add fit().centerCrop().noFade() like this
Picasso.with(context)
.load(message.getMediaUrl())
.config(Bitmap.Config.ARGB_4444)
.resize(w, h)
.onlyScaleDown()
.centerCrop()
.fit()
.noFade()
.placeholder(R.drawable.progresscircle)
.into(messageImage);
Try this:
Picasso
.with(context)
.load(message.getMediaUrl())
.fit()
// call .centerInside() or .centerCrop() to avoid a stretched image
.into(messageImage);
change your Picasso call to this,
Picasso.with(context)
.load(message.getMediaUrl())
.config(Bitmap.Config.ARGB_4444)
.fit()
.centerCrop()
.placeholder(R.drawable.progresscircle)
.into(messageImage);

Picasso center image without resizing into ImageView

I've come across this simple problem with the Picasso library. I haven't find any way to put an image into ImageView center it like android:ScaleType="center" does without cropping. Do you have any ideas about how to solve this ? My problem is that I don't know at the runtime the height and width of the BitMap I download so I can't use resize() properly.
This is a little late, but for anyone who's looking for a solution :
Picasso
.with(context)
.load(ImageURL)
.fit()
// call .centerInside() or .centerCrop() to avoid a stretched image
.into(imageViewFit);
If your ImageView is fixed one dimension and flexible another dimension (ex. android:width="match_parent", android:height="wrap_content"), you should be able to use android:adjustViewBounds="true" to get the ImageView to resize to display your image without cropping.
i am not found fit to center without resizing,
Picasso.get()
.load(source).resize(1650,700)
.centerCrop(Gravity.CENTER).into(imageView, new Callback()

Categories

Resources