How can I load image on android studio by using Picasso libary. I tried it before but no image shown...
Note: Libary implementation, Internet access permission everything I do correctly but nothing happened...
Below is the example to load the image with Picasso.
Picasso.with(mcontext).load(URLDecoder.decode(current.getImage(), "UTF-8"))
.placeholder(R.drawable.program)
.into(holder.imageView);
Share your code here so we can check.
Related
I'm doing a basic Android Studio Project for loading a URL into an ImageView using Picasso with Kotlin. I have followed every step from the official webpage of Picasso, but when I run my app the emulator shows an empty view.
In my Gradle I added the implementation of Picasso:
implementation 'com.squareup.picasso:picasso:2.71828'
And Internet permission within manifest tag too:
<uses-permission android:name="android.permission.INTERNET"/>
And in MainActivity the basic use of Picasso:
Picasso.get().load("http://paproject.online/hp.jpg").into(imageTest)
imageTest is the id of a Imageview with layout_height = 200dp and layout_weight = 200dp.
Maybe Your Photo size is too big so in ImageView tag in XML Edit layout_width and layout_height to Const Size Like 100dp.
and If U can Change Picasso with Glide. maybe Can help you
Your image is larger (1024x768) than your ImageView, but of course that should not be a reason for you to get blank. Try as below which also includes local image resource nopic for the error cases. Seems you have the correct include
// Lazy load the image with Picasso
get()
.load(yourURL)
.placeholder(R.drawable.nopic)
.error(R.drawable.nopic)
.into(img);
You can resize your image before including it into imageView
Picasso
.with(context)
.load("http://paproject.online/hp.jpg")
.resize(200, 200) // resizes the image to these dimensions.
.into(imageViewResize);
Or you can use any cropping technique like .CenterCrop().
You can read more about this https://futurestud.io/tutorials/picasso-image-resizing-scaling-and-fit
Ok, the problem is already solve. It seems that there is a problem loading images in Android 9.0. So the solution is in this link: Picasso image loading issue with Android 9.0 Pie.
Thanks to everyone for your responses.
How to load images in same image view from web or local android gallery?
I have an image view which has three options for loading images templates from web service,from gallery, from camera.I am using Glide library to load images from web service, Now, if i load image from web by glide and remove that image by remove button which i have for removing a picture after i pick image from gallery it doesn't load the image from gallery instead load the same image from glide which i removed before.
write the code like this for loading image .
Glide.with(mContext).load(imgUrl)
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
Glide Library Intoduction Go through with this link, hope it will be work
You can use Picasso library. Image loading using Picasso is very easy, you can do it like this way
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
and in their website you can get every details.
and another Library is Glide. You can use Glide too for loading image..
You can also use Glide:
Glide.with(context).load(image).asBitmap().placeholder(R.drawable.placeholder).error(R.drawable.error).into(imageview);
I am using Glide Library to load image on ImageView from server, but it show only previous image not updated image.
Glide.with(getActivity()).load(profile_image_link).error(R.drawable.placehoder_user).into(iv_user_image);
The most common reason for that issue is Glide caching the image (it still has the previous version of the image in cache).
Try to clear the cache of your app, or uninstall it then reinstall it. You should see the updated image.
If you don't want to use cache do the following when fetching the image:
Glide.with(getActivity())
.load(profile_image_link)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.error(R.drawable.placehoder_user)
.into(iv_user_image)
i have problem, when load image, image is die. How check image is die.
thank
If you are trying to load images from the internet and place them inside a view, but they are crashing you could use Picasso. Picasso will let you load images from the internet, and if no image is present you can use a placeholder image instead. Picasso wont crash if you have a placeholder and a null image from the internet.
I am using glide in my project for the purpose of loading images from the url. But I have another requirement to load GIF image background for my view from drawable folder using glide. I am completely stuck up with the methodology and solutions for loading GIF into my view. I have been struggling with for a couple of days. Kindly please help me with youor solutions to perform loading GIF from drawable using Glid 3.6.0. Thanks in advance. I am posting the piece of code that I am using in my project as follows,
Glide.with(LoginActivity.this)
.load(getResources ().getDrawable (R.drawable.bg_gif));
.placeholder(R.drawable.login_bg)
.crossFade()
.into(relativeLayout);
Note : I have tried using .asGif() method to load, but unfortunately it is indicating the error cannot resolve method asGif()
it may be late now but I load my gif from resources this way:
Glide.with(fragment).load(id).asGif().placeholder(R.mipmap.ic_launcher).into(img);
id is an (int) with the resource file, example:
R.drawable.YOURGIFNAME.gif
In my case I call glide giving a FragmentActivity, but glide can be called different way check docs https://github.com/bumptech/glide
I found out that the gif wont load if you dont add the:
.placeholder(R.mipmap.ic_launcher)
Hope it helps.
Use the following snippet:-
GlideDrawableImageViewTarget imageViewTarget = new
GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(getResources ().getDrawable (R.drawable.bg_gif)).
into(relativeLayout);