How to store large number of .png images in android drawable? - android

I'm new in android and I'm working on a project where i'm using more than 50 images which includes icons and background images. As per android doc, for responsive UI I have to store each image in 4 format i.e. hdpi, mdpi, xdpi and xxdpi. I followed the same but after that I noticed that there are 200 images in my drawable folder(50*4). So my question is whether Im doing right thing or not? because it increases my project size.

whether Im doing right thing?
Absolutely not if you store this 200 images inside your app than your app size is too much high and no one can download the app also there is some performance issue so this is not the right thing at all
Answer 1 -
Best way is to use fontawesome these will generate image from your ttf file dynamically you just need font.ttf file but disadvantages in this approach is there is less number of font/images available for free version if you want more number of images than you have to pay you can refer this
Answer 2 -
Go for Cloud storage means you need to store your image in one of cloud storage than download from cloud they provide API for upload as well as download images refer this But ill suggest you to go for cloudinary.com i have used this and easy to implement API , API for nearly all Languages and Its Free Free Free .......
Best of luck

You have to try the vector drawable images. It contains the code path, so automatically it will expend to all size.
for more info
https://developer.android.com/guide/topics/graphics/vector-drawable-resources.html
https://developer.android.com/studio/write/vector-asset-studio.html

Related

How can you support multiple devices with expansions?

I'm working on a android app that will display gemstones. Putting thumbnails in drawable-XXSIZE is not a problem, but how can I continue this with expansion files?
If I create folders such as: drawable-ldpi, drawable-mdpi etc. and put everything in a zip (I can only have 2 expansion files) will I be able to download only what I need? (I'm guessing no...)
So how can I make sure the tablet user will get big image for full screen such as 1920px (worst case scenario) and for mobile phone alot smaller.
What is the best approach for this kind of applications?
Should I just put it on my own server and make my own image management?
I would like to just put it in a bundle and the end user have an app that is as small as possible without loosing quality
You need to try sdp library for this
https://github.com/intuit/sdp
After this your problem is solved and also try vactor images so you do not need different image size in all folder like mdpi or ldpi or xxhdp ,need to store single vactor image in drawable folder.
There is no solution to this. I just have to build functionality. Previous answer it has nothing to do with my question

Is there any recommended number of files/Images to be stored within Android project?

What is the correct way to store files within Android Project?
All files in local folders? All in webserver? 50/50 ?
The reason I am asking is because my project's size has been increasing a lot due to the number of drawables and I am afraid I should do something about it.
Can this compromise the app performance?
The large app size i.e. apk file size might not compromise your app performance but, will certainly make it slower to install your app. From the user's perspective, if two apps provide same features and have similar performance the size of their apk files will be the deciding factor for them to install your app.
Using web server to save drawables can be an efficient way if your app is a web based app. In case, your app does not require web access or internet access for any other purpose, don't save drawables on the web server.
However, I would suggest you to reduce the size of your drawable files in such a way that their quality is not effected. All this can be achieved by help of tools like Photoshop (I have personally not tried this but know that it is possible).
You can also use nine-patch drawables. These drawable files can stretch themselves along the sides specified without compromising the image's quality. For more info on the same visit following links:
http://developer.android.com/tools/help/draw9patch.html
http://developer.android.com/reference/android/graphics/drawable/NinePatchDrawable.html
Also, make sure that your icons are of specifications as specified in the Material Design Guidelines. Visit the link for more details: https://www.google.com/design/spec/style/icons.html#

where to store images?

I am creating an app that uses more than two hundred images. To display images, lmageView is used. My question is- Is it necessary to put images in drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi. If I put the images in these four folders, does my app size increases?
Please help me. Thanks in advance.
Well I guess if your image set will not change in the future maybe that's the best place to store them. Your app size will certainly increase, however, if that's a concern you can store them using any cloud service like parse.com or firebase, so you can retrieve them later using a library like picasso
You don't have to put pictures in all folders. There are folders for different image resolutions. You can use a single folder called drawable or just use drawable-mdpi. The app size increase with multiple image versions. There are some disadvantages when you use only one folder.
If you have big resolution images inside your folder: For a presentation, small screen devices have to minimize the image. This costs hardware ressources. If it costs to much ressources, your app will crash.
If you have small resolution images inside your folder: For a presentation, big screen devices have to upscale the image. This will result in bad image quality.

How to handle large images in android

i'm writing a simple application. i need to handle around 100 images having size dimension 1000*740. images are fixed no need to change. user will see this images like gallery view.
Problem
1.Large number of Images increases .apk filesize .It crosses memory limit(Given by Android market).
2.I placed these images in Drawable folder.Is there any other way to keep this images?
Any Idea?
YOu can host them on a separate site, but you do not have to download them every time. You can download them to an external directory (sd card) and just check if you've got everything you want when starting the app: If you do, you obviously don't have to re-download the shots again.
Is there a reason your images are of that size? If you compress them a bit you should be able to fit a photo in less then half an MB, and I think that the limit is 50mb on the market: You might be able to just squeeze it in.
Upload all the images to a link. Do parsing by using that link.
That's a pretty tough dilemma. Perhaps the user can download the images instead. You could use flickr to host the images.
I would suggest hosting them somewhere and download as "citizen conn" suggested.
Another possibility would be to separate in different sets and have different apk with those (maybe some of them would only have a content provider with some of those pictures). But that's kind of ugly...
Other than that, I don't think there is any way to get around the limit from Android market...

Smaller APK size with large assets?

I am creating a simple android app to view a comic book. The pages are large(0.5-1 mb each), high quality .png's and I am loading them into a webview to make use of the built in zoom controls. So far I only have 17 files and the APK size is already about 16 mb. I'm looking to add over 200 files in future updates. I can't really reduce the quality too much because there is small text that must be zoomed-in on to read. Any suggestions? A similar question was posted here: How to reduce App (.apk) Size, but I don't want to lose the quality of the images. I'm not sure if it's appropriate to link to here, but you can have a look at my app by searching for Tracer (by Detour Mobile) on the android market if it helps at all. Thanks in advance.
You could compress them without using lossy compression- e.g. zipping/rarring them, but I don't believe this would gain you much more than a few kilobytes here and there. Otherwise, try using a more compact format than PNG, such as JPEG (you won't lose too much quality.) By the way, all of this was suggested in the referenced post.
If you do decide to scale down the images' size somewhat, be sure to use a method like bicubic sharper- it tends to look better than others when reducing image size.
Another option would be to download the images for the comic that is being read on-the-fly with pre-fetching so reading would not be interrupted as much.
Consider placing your images in Assets folder as opposed to Res. The big difference is, Assets content won't be compiled into R.java class so you will see major storage savings. You'd have to modify your code though as you won't be able to call up the images via the regular r.resID notation, but it's doable
android offers a new way to deal with it.
android app bundle apk size has a maximum size of 150mb
but you can use an asset pack to seperate the apk from the static files
and upload your app
here is a more detailed explanation about asset packs:
https://developer.android.com/guide/playcore/asset-delivery
here is the guide for integrating asset packs with regular android app:
https://developer.android.com/guide/playcore/asset-delivery/integrate-java

Categories

Resources