In my android app I want to show a background animation.
I had done it using images by changing the images with time.
But my problem by using images for each frame of animation the app size was becoming huge
I know it is not a good way.
I want to do it in efficient and good way.
If I am doing this by using images which is the best way. How can I do that?
Images are always a thing which uses more memory in android. If you are using images there no way by which you can make application to use lesser memory it will just use memory depending on image size, but there is a way which I follow. If background animation with images was a need then I would use optimized images. Optimization's like using images that suits the screen resolution, size and so on. Further more I would go with having different sized images for different screen resolutions so that size of images would be lesser for lesser screen resolutions. Hope that helps you a bit at least.
Edit :
Here under Using configuration qualifiers you will find about having XML files. You should use timer for that as you need to change the images at timely manner. If you don't want to use timer then go with this.
After searching a while I came to know about this (http://www.edumobile.org/android/android-development/frame-animation/) solution.
Related
Does android want that we put different version of an image (for different dpi) to avoid resizing-artifact because their scaling algorithm is not quality-efficient (to be fast i think) ?
But anyway, it's obvious that android will scale all image just for maybe some pixels, so, resizing-artifact does ONLY appear when we do a big resizing ?
Through this questions , i want to understand the utility of putting different size of image and why we don't just put a big resolution image and let android scale down every time.
(I have also a suppositon that i want to confirm, maybe the algorithm take more time when the scale factor is important)
Thx.
If you put the highest quality images in your app, your app consumes more memory (RAM) and if the device has less memory than your app freezes more frequently. This will not provide a good user experience as we all want that our app should be smooth in performance.
Besides all, I had also tested that if we put larger images and try to display them, Sometimes the app also crashed by giving an error of out of memory.
If you want to only place one image in your app to reduce the size of your app than I advise you to do it with .svg images. These images are scalable and the CPU does not have to do extra processing to display them.
I hope it will help you. Thank You
I have designed an in-app keypad for my Android application and I need to provide an image for every key. Currently I've only loaded one large image for each one that is being scaled down to adjust to the layout. Also, this looks nice in every resolution.
Is this approach acceptable or should I provide different images for different screen densities? Currently I've placed those inside the generic drawable directory.
You should. Some mobiles with lower resolution, usually won't have much memory. Loading large images in small screen takes too much memory, which might end up crashing. So if you give different images, then according to density it will take appropriate images. check this out.
It's acceptable in some cases but certainly not optimal.
For best memory performance and the least amount of artifacts I would still recommend to provide alternative bitmap resources for different densities, like the Android documentation recommends.
I am developing an android application which displays an image as background. I have read the documentation and it says that Mdpi should be the base line and all other dpi's should be relative to it. But I am not able to decide what should be the resolution of background image in pixels I should for all the dpi's?
Any suggestion?
The best approach depends but, to save space and retain resolution at all densities, include only a single image in your app. When your activities load, use a scaled load based on the the DisplayMetrics of the device. If you aren't worried about resolution, then scaling up from MPDI is fine (but I'm pretty sure you're asking because resolution at the higher densities is a concern, and based on your background image size).
The advice for "starting" with MDPI has to do with the numeric scaling that is needed and being able to conceptualize it. In other words, it is easiest to "think" about how scaling works on Android when you start with MDPI. After that, your use-case is far more important.
There are many examples for scaling images based on your needs. Do not forget to use caching whenever possible, if your application loads several.
Another thing to consider is the extended heap memory, if you encounter OOME because of iamge handling issues.
I am saving 4 copies of every image in my game, each with a different density. They are saved in the relevant res/drawable-* folder, and it seems to be working great on various devices.
So, currently, I open up photoshop, and have one psd for each image. I edit the vector's appropriately, change the density, and save the image in the appropriate folder. I have to do this 4 times, for every image. It takes forever, and I am trying to avoid getting sloppy and messing up one density of one image and not noticing it.
Is there a better way to this? When you have to create and edit your drawables over the course of development, how do you do this?
Check out batch processing in Photoshop. It will be the same thing you do, only automated
http://howto.wired.com/wiki/Batch_Process_Images_in_Photoshop
As we know it there are several screen layout out there on various android devices. Now, my question is, what's the best solution for displaying image on screen (full sized image) on that various device?
Should I (this is several strategy I have in mind right now):
resize every images for that target device? (with the cost of resizing it and lost of quality on larger device)
create several images for all or several common screen size? (with larger download size)
create core application and let them download images appropriate to that screen size (that means, I have to prepare hosting of those images)
something I don't know yet...
So, if you guys have experience in this kind of situation, your recommendation is greatly appreciated.
Update: My application will have several (20-30) images.
This is documented ( http://developer.android.com/guide/practices/screens_support.html ) and answered quite a few times already I believe.
Create different images for the different screen resolution (store in drawable, drawable-hdpi... accordingly).
You can also define different layouts for different screen sizes (although to display full screen images, it does not sound like you need that).