Currently I'm working with an application where one activity holds a list view with image and text for each row. I'm downloading the images using the volley. When the list view item is clicked the app will switch to a another activity with a detail view where a large version of the clicked image will show. For the both time I'm using NetworkImageView.
Images are loaded in the list view with caching. But the problem appeared on the detailed view. The images are showing from the previously loaded cache with low resolution. I want to load a good resolution image on detailed view which will cache the image separately for large view.
For the both screen image url are same. How to do that ?
Thanks in advance.
First thing is a bit obvious - make sure you images are at the wanted quality.
If that's the case, you'll probably want to load the image "manually" using the ImageLoader class, as the NetworkImageView by default, optimizes the size of the Bitmap it creates to be the size of the view itself. So what happens is, you first load the thumbnail view which is small, and the saved Bitmap is created in that size instead of the original image size. Then, when the bigger view requests the same image, the cached version is returned which is a small Bitmap, and the view scales it up, creating the low-res appearance.
Try using ImageLoader.get() with the width and height appropriate to the bigger view in the detail screen.
The other alternative is to load 2 versions of the same image.
Related
I am really trying to figure out which is the best way of loading a huge image in Android ImageView( or some other view extending ImageView).
I am aware of OOM issues with Android framework when working with bitmaps but still I need to implement the following requests:
horizontal scrollable imageview
must load a huge 8000px (keeping original image quality so no downsample) width and device height png image from drawble-nodpi in it and to be fluent while scrolling it without preloads or lag(recyclerview will have blinks so it is a no go I tried that)
I am thinking at a customview extending imageview and something to decode only current scrolled region from that bitmap but I am stuck here
avoid oom
also does a pdf viewer library be better than using huge png from performance point of view? I need the picture preloaded on app start not lazy loaded
I have used both Picasso and Glide in order to load images asyncronously in grids with images coming from the phone's external memory and in order to download photos from the Internet.
But now for my Android game in the first screen I need to display an image below a title (the image takes up all available height). Then the user taps on a specific part of the image and the game starts.
The image content is a drawable resource.
So, for this specific use (a TextView and an ImageView below it which takes up all the remaining space), what should I do:
-Specify the image as ImageView's src property.
-Use an image loading library, such as Picasso or Glide
What do you suggest and why?
Thank you.
EDIT: The image would be static, a static drawable resource.
I have got an activity where i download images from a server and display them in a gridView.
Then If i click on one of those images I open a new Activity where I display the full screen image. Now if I get back to the first activity, the one with the gridView, images are downloaded again.
I am using Picasso for displaying images either in the gridView and in the following activity.
Is there a way to avoid the downloading of the whole set of images in the gridView EVERY time I go back from the second activity?
When picasso download an image it saves it to the heap memory, if the images is too large for the heap they are not cached. So if you have grid view full of images, use picasso's ".resize()" to down scale those images and ".config(Bitmap.Config.RGB_565)" to use 16 bit colors (you won't see a difference in the quality, but there is significant difference in size).
Ex: picasso.load(url).resize(200, 200).config(Bitmap.Config.RGB_565).into(target);
I have an image that is to be displayed in about four different sizes depending on which activity the user is viewing. For instance a ListView will show one size, a GridView will show one size, a slide show will show one size, etc. If I use Picasso, will it download the image once or will it download one image for each size? Of course, I am taking into account that Picasso caches images (which is what I want). The key point here is that I have a single url for the image since it is one image.
Note that to keep the example simple, I mention one image. But of course I am talking about a set of images each of which needs to be manipulated as mentioned in the paragraph above.
If I use Picasso, will it download the image once or will it download
one image for each size?
Once for the original size as you get from the URL.
You can use the resize() method to resize the image and the original image would still stay at full resolution. I have done that in my app where I displayed a 600x600 image at 150x150 in a thumbnail and in full resolution later.
I have a lazy-loading ListView populated with images gotten over the network. The list rows are set to wrap_content, so once the image loads it resizes and the full scale image will be displayed. It looks great when scrolling down, but when scrolling up the rows resize and force the bottom rows off the screen. How can I prevent this jumpy scrolling while scrolling up?
----- EDIT:
The images are comics of varying sizes. Some are 2 or 3 frames where they aren't very tall. Others are single frame comics where they are much taller. The image needs to take up the full width and the height should not cut off any of the comic.
Assuming all images downloaded are expected to be around the same size, a good solution most developers use is to use a "dummy" image until the real image is loaded. This image will exist locally so it can be loaded almost instantaneously. In the getView method, show this dummy image until the real image is downloaded, and then simply replace it. This will prevent your rows from resizing.
you have to see this link It downloads images in the background thread. Images are being cached on SD card and in memory, It decode images with inSampleSize to reduce memory consumption and also try to handle recycled views correctly. Play a fake image when image are not completely downloaded. "sorry fo the music!!"
I figured out the solution. When I receive the image, I get the width from the parent then set the height of the image view to parentWidth * bitmapHeight / bitmapWidth. That way the resizing occurs as the row's view is created and the list doesn't jump around as much once I know the size of the bitmap.