horizonalscrollview to many images? - android

sorry I'm really new at this, hopefully I posted in the right place.
I'm trying to make an app to change my wallpaper, but i'm stuck. If I add more than about seven images to my xml the app just closes itself. My images are 960x854. Does anyone know what i am doing wrong?

See these threads:
Android - how to improve HorizontalScrollView that has lots of views/images inside
http://groups.google.com/group/android-developers/browse_thread/thread/816292b2970f2ccd?pli=1
It would seem that you're running out of memory. Using Gallery instead of a HorizontalScrollView would be a more memory efficient way of handling what you're trying to do as it doesn't have to hold all images in memory.

Related

Imageview down the performance of my app

I am working on an Android app where, once a user clicks a login button, the app launches an AsyncTask to verify account details with a remote server. That part works fine by itself and doesn't make my app slow. However, when you click the login button, it launches a second activity where I have 4 ImageViews. When I added that part of the app, it became significantly slower (from less than a second to about 5 seconds loading time). I load the images into the ImageView from the XML layout file directly, so I'm not sure what I'm doing wrong.
My question is that do ImageViews make your app slow, and if so, how do you optimize their performance?
I was working my own app when I actually experienced this too. The reason is because if the files are to big they take a while to load into memory and set as the Image View. There is two ways you could really sort it out.
1: Get a smaller version of the picture. Smaller pictures come up faster and aren't prone to an OutOfMemory exception which kills the app :(.
2: A better way is to use the Picasso api. I used this APIs to add images in list views, expandable list view with pictures in them. The app was fast and fluid :)
Picasso's api would be your best bet ant it is easy to implement.
Edit:
Here is the link to the site to get the APIs :)
Picasso
The only way I could figure this out is to create an image in photoshop that has all the buttons laid out where you want them on top of the image. Interpret it into your app and put regular buttons over top of the imagebutton pictures that you placed onto your background image. Set the size accordingly to your images of your buttons and then set the background of each button to #null so they aren't seen. Now trying to figure out how to interpret this into orientation view even though I don't think I'll be using orientationview. OH AND CHANGED THE EXTENSION TO A GIF TO SAVE ON DATA RATHER THEN PNG.
Hope this helps I'm sort of new at coding on android as I have lots of experience with HTML .
Cheers
THANKS FOR THE DOWN LIKE I WAS SORT OF NEW AT THE TIME OF NOT KNOW OTHER WAYS TO SET THIS... THANKS THOUGH, MORONS

Rendering large images in WebView

I'm a newcomer in development of android apps. But, I'm undertaking what feels like a large project and I'm looking for information on whether it will work or not, before I get to far in.
As I've read, when trying to display very large images in android, it is most useful to use the "webview".
So, I took that advice, split my image into 1024 smaller images, and laid them out in an html table (not quite finished yet). Now, I'm noticing as the table gets larger my phone begins to lag upon scrolling.
My question is, is webview trying to render every single picture at once upon loading? If so, is there a way to make webview only render a set of images at one time? Let's say I'm at 14,000X x 24,000Y on the image, can I set webview to render the next 5,000px in each direction only, or is this necessary at all?
I can't seem to find the information I'm looking for, but will continue to search. Otherwise, any and all help is appreciated. Thanks!
i have exactly same problem and i found use full this library:
https://github.com/nostra13/Android-Universal-Image-Loader
you can configure a lot of parameters and using cache..

Best Way to Animate images frame by frame in Android

I have 3 sets of 50 images and I have to create the animations for each set of images in Android application. I am able to create a simple application which animate first set of 50 images using the below method,
Added Animation-list xml in drawable folder and called it using frameAnimation.start().
This method didn't work until I kept the following "android:largeHeap="true" in manifest file.
I am not sure whether this is the good way to animate the images (if we have more number of images and each image of more size like 60 KB. Image is JPG format) or not
I browsed and I found that, if we are able to clear the memory and if we are able to maintain less number of images in memory, then our application will work very fine. So I want to know how to clear the memory?
Please let me know do I need to follow different method to animate the images other than I explained above, so that I can clear the memory.
Thanks for your help.
After looking into several posts and doing much research, I finally ended up modifying the images in Imageview programmatically to simulate frame animation. That way I am just maintaining three images in cache at any point of time (previous, current and next one). I hope that this will be useful to others.
It is not a good thing to process a large amount of images in a frame like manner in Android itself as it will trigger the dreaded "Out of Memory" exception.
Clearing the memory itself is not possible. The best fix for this is proper bitmap handling of the app.
I'm not sure but you might want to check on PhoneGap.
Its an HTML5 Engine that we used before to create a game.
By drawing into the canvas itself, we've recreated frame animation with it. It just requires WebDev skills though.

Download images and put them into ImageViews

Hi and happy new year!
I'm trying to download images from internet and put them into different ImageViews. The ImageViews are dynamically created as the user scrolls. When user arrives to the bottom of the scrollview, I load 10 images more.
The images are loading ok, but when i have a lot of images I get a java.lang.OutOfMemoryError.
I know the problem is that I have a lot of images consuming a lot of memory, so... what's the way to go on my scenario?
Thanks!
Try using a ListView instead of a ScrollView. Then you can use a lazy loading technique like Universal Image Loader. The ListView utilizes view recycling which will be easier on your memory, and you can also cache images using the image loader. This library also has a few options for memory management as well.
You are going to have to keep track of the images you have loaded and start recycling them when they are out of view.
You might find the LruCache a valuable tool. There was a good talk at IO12 "Doing More With Less: Being a Good Android Citizen" that went over lots of memory issues and includes some discussion on how to use the LruCache starting around the 4 minute mark.

Out of Memory with ListView

I am very familiar with OOM concept. I have come across so many questions that have been asked here and I know this could sound like a repeated question on OOM, but I have a different problem now.
I have hundreds and hundreds of images, which I have to show in a single ListView in a single Activity.
I have made use of the Fedor's lazy loading concept.
The code works fine when the images are little(something like 50-100 images), but if I get around 200 to 300 images, as soon as the user makes a scroll through the ListView (eventually) I am getting an out of memory exception.
I am using the efficient Adapter concept as shown here in developer site and I believe that this is the best custom adapter usage method.
All the suggestion what I have seen so far is based on reducing the bitmap size by scaling it or some other means. I have already tried those methods. But still the OOM occurs in some point of time.
Reducing the quality of the image doesn't look like the way to handle this Exception , because which seems to affect user experience and, also, it doesn't work for a large amount of bitmaps.
My questions here are:
How do you display n images in a single ListView without facing OOM?
What are the best strategies to follow in this scenario?
Is it possible to show around 500 images in a single ListView?
Any help is much appreciated.
Look into googles shelvesproject.
Shelvesproject does following: uses a placeholder image while loading image, use weakreference for storring images, delayed handler updated with clearing.
Yes and no, it is possible to have listview with this many items but its not possible to have this many images all in memory at the same time.
Try with API Level 11+ images before this API Level are placed in application heap. And yes it is possible to have a List View with a 500 images and working smooth (Contacts application for example).
This http://code.google.com/p/android-imagedownloader/ may help you getting images, cache and recycle them.

Categories

Resources