I am working on an android application with a bunch of clickable gifs.
I created a gridview of gifs that is scrollable. The gifs are a gifmovieview from https://github.com/sbakhtiarov/gif-movie-view. The images keep loading into the memory each time I scroll, eventually causing a OOM error after scrolling up and down the list about 6-10 times.
How can I fix this? And possibly add smooth scrolling?
You're probably keeping all the GIFs in memory. Use an LRUCache to limit the number of GIFs in memory at a time.
Smooth scrolling issues are probably due to image decoding. Move that to a separate thread, and show a placeholder image until its done.
I wasn't recycling images properly, so they weren't getting removed or reused from memory and kept getting added on top of each other.
I changed convertView!=null to convertView==null and put the inflate inside of it.
Related
I am using two ImageViews as a background for my app and its terribly slow so i need to figure a way to transition these images with a fade like transition without using two different ImageViews and simultaneously changing the alpha levels when the button is clicked.
the effect im trying to achieve would be similar to this
img1.setAlpha(0.0f);
img2.setAlpha(1.0f);
img1.animate().alpha(0.1f);
img2.animate().alpha(0.0f)
but i need to achieve an effect similar to this using only a single imageView and changing the image resources.
I'm currently working on an application where I at one point want to open an Activity that has a transparent background so that I can see the activity below it. This was simple enough and I solved it quick. However, now I want to also add some kind of blur filter so that the activity below my activity seems blurred out.
I have searched around and tried several different solutions but with no luck so I'm trying to add this as a question. Does anyone know of any good way to solve this?
Thanks
There are plenty of libraries that do this. Here's one list of them. Personally I've used BlurView (I hope linking to one of the libraries is not against site rules) but I've had to patch the library a bit, see this issue - the pull request is not in yet. I've also had performance issues with animations.
Basically all the libraries do the same things:
Create Canvas for a Bitmap, with scaled down dimensions (e.g. 4 times smaller), set the transformation matrix to apply this scaling
Render the background of the window to Canvas
Render the root view of the Activity to the Canvas
Blur the Canvas's Bitmap using ScriptIntrinsicBlur
Draw the Bitmap as the background of a View, scaled back up e.g. 4 times
Why the scaling? For performance reasons. It's much faster to draw everything 4 times smaller, and also the blur effect becomes "stronger" due to the upscaling - there's a limit how much ScriptIntrinsicBlur can blur with one pass, and multiple passes slow things down again.
For API < 14, you could use the flag WindowManager.LayoutParams.FLAG_BLUR_BEHIND.
For higher APIS this is no longer supported.
However, you could do this with a view.
Create a Bitmap from your activity's overall layout and Blur that bitmap with whatever method you want. Add(or unhide) a View in your layout that covers everything and you have your problem solved.
I'd like to implement something like a slideshow on AndEngine. I need to show a big images(2000x800px). I'd like to have near 10 images but only 1 image can be displayed on the screen in one moment of time.
The main issue is memory management. I don't want to load all images in memory at once. I think the best idea is to load one image after the other(when the image is needed).
How to correctly load images in this way ? Also, how to correctly unload previous image from memory ?
I have a widget with ViewFlipper that flips between X number of images. I aim for 10 images to be flipped, and I can do this if I load very small images. My widget is size 4x2 and I want to display images with good quality, but I can't achieve this. Everything loads fine, no exceptions, but the widget never displays them. If I load very small image sizes (100x100 px), it starts flipping them. If I load larger image size (300x300), it won't start flipping the images until I reduce the number of images (flips) to 4.
This suggests a memory limitation to me, but I would expect an exception to be thrown somewhere after I do appWidgetManager.updateWidget(widgetId, remoteViewFlipper).
Going through the logs, I don't see anything nearly related to this.
I think it depends on concrete implementation of launcher - widget stuff is hosted and processsed there. You updtes are send as parcelables, so there soule be data size limit as well:
http://groups.google.com/group/android-developers/browse_thread/thread/26ce74534024f41a?pli=1
One particular activity uses a gallery view and many images that are displayed when one item in the gallery view is clicked. When you scroll through the gallery, the scrolling is very smooth ONLY if one certain image is commented out (even if 40+ images/textviews are displayed). We've tried changing the resolution of that image, changing the scaletype, but it still lags the gallery view. This image takes up a large portion of the background. Have you ever encountered any problems similar to this? We would really appreciate any advice you have to offer.
Try loading the image with ImageIO. Then check the type of the BufferedImage it returns (BufferenImage.getType()). Most likely it is not TYPE_INT_ARGB or TYPE_INT_RGB. (Probably TYPE_CUSTOM.) When this is the case there is a conversion being performed on every paint.