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);
Related
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();
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 successfully upload my image to firebase but how can show every image in the firm of card view and make it clickable to open activity
You can place an ImageView inside cardview and use Glide library to fetch the image from firebase. Below is the code snippet
String imgUrl = "url to image in firebase";
ImageView iView = (ImageView) view.findViewById(R.id.imageView);
Glide.with(mContext).load(imgUrl)
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(iView);
There might be other ways but i used this and its fast and simple. Hope it will help you. Thank you.
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'm using Picasso for downloading images from URL and putting in ImageView. Images are rectangle, but my ImageViews are squares. So I need to use some cropping, because I have spaces on top and bottom.
Without cropping the image is clear:
Picasso.with(context)
.load(left.get(pos).getImageName())
.into(ivFrontPageLeftImage);
To fit inside and crop I'm using:
Picasso.with(context)
.load(left.get(pos)
.getImageName())
.fit().centerInside()
.into(ivFrontPageLeftImage);
But as you can see the image is not clear, it is blur.
So how can I fit image inside the square (ImageView). Also image need to be clear, not blur?
I download this image, crop it with size 300 x 300 (to be square, i cut from left and right) and upload it. I use this new image to put in ImageView:
Picasso.with(context)
.load("http://oi62.tinypic.com/29y61p3.jpg")
.fit().centerCrop()
.into(ivFrontPageLeftImage);
As you can see image is clear and it is not blur.
How can I do this programmatically? Is it possible with Picasso, or I need other library to do this?
I can't comment on Lee's answer as I don't have enough reputation. But his answer was correct as I had the same issue. You can also set it in the ImageView object by doing the following:
imageView = (ImageView) view.findViewById(R.id.img);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
Apply center crop on your ImageView instead of the method you are now using.
<ImageView
...
android:scaleType="centerCrop"/>