I want to make multiply loading of photos in each cardView at my news feed, like at facebook application.
I found fresco library, but I don't have an algorithm to doing such loading and resizing.
Help me please.
First you need to simply add the following line to the dependencies section of your build.gradle file:
compile 'com.facebook.fresco:fresco:0.12.0'
You use below links for resize:
http://frescolib.org/docs/resizing-rotating.html
https://guides.codepath.com/android/Displaying-Images-with-the-Fresco-Library
Once check for Glide as well
Related
I'm using Fresco library to show images full screen. How to show animated GIF images full screen using that library? Is there any other optimal solution?
You have to add the dependency for Animated GIF decoding to your Gradle file:
implementation 'com.facebook.fresco:animated-gif:1.12.1'
Then, simply load the image into a SimpleDraweeView:
mSimpleDraweeView.setController(Fresco.newDraweeControllerBuilder()
.setAutoPlayAnimations(true)
.setOldController(simpleDraweeView.getController())
.setUri(yourGifUrl)
.build());
I'm new to Kotlin and Java and don't know how to scale an image in an image view.
I want something like this: MyImageView.setHeight(300)
I don't want to distort the image.
Thanks in advance!
This solution might be overkill for your current question, but if you have to show images in your app, I recommend using an image handling library such as Picasso or Glide.
If you are to use Picasso, add it to your dependencies by adding the following line to your gradle files :
dependencies {
implementation 'com.squareup.picasso:picasso:2.71828'
}
Then in your Kotlin file, when you are about to load the picture onto an ImageView,
do it using Picasso using the following lines :
Picasso
.get()
.load(imageUrl)
.fit()
.centerInside()
.into(imageView)
Yes, I agree with rgv. Use an image handling library, preferably Picasso. It can reduce a lot of hardwork and also, the result is better than what you would have got by scaling image manually.
I am working on an application which uses Google Firebase and RecyclerView. While retrieving the images from Firebease, images are not properly scaling up. When scrolling the recyclerview, sometimes images are showing as smaller ones and sometimes bigger. They are not scalling properly. I am using Glide to load the images. Please help me .
Also, is it a good idea to use Recuyclerview to use in complex application since OnbindViewHolder being called multiple times causing performance issues. Is there any alternative for that.
Please use this code:
Glide.with(profilePhotoImageView.getContext())
.load(profilePhotoUrl).centerCrop()
.transform(new CircleTransform(profilePhotoImageView.getContext()))
.override(40,40)
.into(profilePhotoImageView);
This means that you are setting a fixed width and height. In which profilePhotoUrl is the url of your image and profilePhotoImageView is the ImageView in which you want to display the image.
And don't forget to add the latest version of Glide in your build.gradle file.
'com.github.bumptech.glide:glide:4.0.0-RC1'
Hope it helps.
I have 4 images set as a background of screens in my application and displaying them cause lags in application. They have 1280x768px and about 70kb. How can I display them without loosing performance?
To use Picasso, simply add this to your gradle:
compile 'com.squareup.picasso:picasso:2.5.2'
And then, in case you have this image on our project folder:
Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Instead, if you're downloading the image:
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
Source: http://square.github.io/picasso/
Check google's sample project here: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
I have an image that I want to download from online.
http://luxproperty.kaytami.com/platform/media/image/jpeg/2014/12/24 Repulse Bay Road.jpg
I have replaced the space with %20, so it becomes
http://luxproperty.kaytami.com/platform/media/image/jpeg/2014/12/24%20Repulse%20Bay%20Road.jpg
The image is not large and so I assume Picasso should be able to load it.
To fit my imageview, I have fit() the image, and the code is as follow:
Picasso.with(mContext).load(UrlEncoder.encode(district.getImage_urls().get(0))).fit().centerCrop().into(holder.image);
However, the image does not appear.
There is a list of 4 items, each containing an image that I load from online. three of them were loaded properly, and the remaining one (http://luxproperty.kaytami.com/platform/media/image/jpeg/2014/12/24%20Repulse%20Bay%20Road.jpg) just does not show up.
Any idea?
I am using Picasso 2.4.0, okhttp-2.1.0 have a look this
It's a bug that is reported to be fixed in the next release of the lib.
You can clone the repo of the lib and compile your own jar or wait.
I recommend you to take a look at Glide. Migrating from Picasso is quite trivial, it has better performance and it makes a nice smooth scrolling on lists.
I had the same problemm when i tried to use Picasso to load images but i used this Library
Its the simplest thing so far by me.
Compile:
compile 'com.koushikdutta.ion:ion:2.+'
Then:
//for activity
ImageView myImage = (ImageView)findViewById(R.id.my_image);
//for fragment
ImageView myImage = (ImageView)rootView.findViewById(R.id.my_image);
Ion.with(myImage)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.load("http://example.com/image.png");
Hope it helps!!!