I am using Glide to load image in image view but images are not loading in full width as image view they are leaving some empty space on both sides.
This is what I have been trying so far
RequestOptions options = new RequestOptions();
options.fitCenter();
Glide.with(context).load(model.getBannerImage()).apply(options).into(offerImage);
This is what I get after image loaded in image view it shows empty space on both side how can I get this image in full image view someone please let me know any help will be appreciated.
THANKS
Use android:scaleType="centerCrop" in your ImageView XML code.
Please try this:
RequestOptions options = new RequestOptions();
options.centerCrop();
Glide.with(context).load(model.getBannerImage()).apply(options).into(offerImage);
also you can set in xml (ImageView):
android:scaleType="centerCrop"
Use centerCrop in RequestOptions
RequestOptions options = new RequestOptions();
options.centerCrop();
Related
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);
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));
I am trying to display the image in this link: https://dl.dropboxusercontent.com/u/11469423/m6.jpg
in an imageview. i referred to some posts and i did it the following way:
URL url = new URL("https://dl.dropboxusercontent.com/u/11469423/m6.jpg");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
mIVPic.setImageBitmap(bmp);
but at runtime, the imageview is displayng nothing.
please let me know why the image in the link is not getting displayed on the imageview and how to do it
Take a look at the picasso library
Then you can do things like
Picasso.with(context)
.load("http://i.imgur.com/DvpvklR.png")
.into(imageView);
I have to show load GIF image from drawable to ImageView using glide.I have tried with following.
Glide.with(LoginActivity.this)
.load(getResources().getDrawable(R.drawable.bg_gif)).asGif()
.crossFade()
.into(relativeLayout);
But isn't seem working and it's working when I'm place image in raw folder.but the problem is I have to use different dimension images.
Any help would be greatly appreciated.
You can try to use Ion it works fine for me.
Ion
Using Ion
Ion.with(imgView)
.error(R.drawable.default_image)
.animateGif(AnimateGifMode.ANIMATE)
.load("file:///android_asset/animated.gif");
Using Glide
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
Another Approach
For Glide 3.0 you need to set asGif() earlier:
Glide.with(context)
.load(imageUrl)
.asGif()
.placeholder(R.drawable.loading2)
.crossFade()
.into(imageView);
Keep in mind that just using load() will load either a GIF or a Bitmap depending on the type of the data. Unless you want your load to fail if the given url is not a gif, you don't need to specify asGif()
Just pass the resource id directly to load():
Glide.with(LoginActivity.this)
.load(R.drawable.bg_gif)
.asGif() // you may not need this
.crossFade()
.into(relativeLayout);
Steps to load Gif images from drawable
You need to move your Gif image tores/raw folder of your project
(
if your project don't have raw folder in resource directly then simply make one and put your gif in it )
and then you can simply load your gif with just one line of code
Glide.with(this)
.load(R.raw.splash)
.into(new GlideDrawableImageViewTarget(
(ImageView) findViewById(R.id.image)));
Place your Gif in the "raw" folder and use
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.test).into(imageViewTarget);
For Glide 4
GlideApp.with(this)
.load(R.raw.gif_file)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.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()