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.
Related
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
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
Let's say I have 100 PNG files (images) I want to use in my Android app. If I add them all in the drawable folder, would that be a performance impediment? If yes, what alternatives do I have?
I mention that I won't use them all at the same time. Most probably, I will need 6 of them at any given time.
Only storing them in a folder would not be a performance impediment.
As long as you do not load the images in your code, performances are not involved.
Then it's up to your use to choose to load them all at the start of your app, or on demand when your app is running.
It shouldn't impede the performance of your app in any way, however you may want to consider clever ways of compressing the images to reduce APK size or the times to load individual images i.e vector drawables or webp.
See https://www.youtube.com/watch?v=r_LpCi6DQME
How to use single drawable folder for all images by which apk size can be reduced ,I have seen many posts but every post says that its necessary to use all folders(hdpi,ldpi...etc).Is their any way to use single folder and get good quality images
Different drawable folders are used for a purpose, i.e when you want your app to be compatible across number of devices. There will not be any issue even when you use a single folder for all images, but when u test or run the app across number of devices you can see that sometimes the image is big and sometimes small.
So its always advisable to create multiple folder so that you'll get the perfect image for that resolution device.
you can use drawable in xml such as shape. It's only use drawable folder.
If you want use only one folder, then you can chose the xhdpi or xxhdpi folder. Zoom in bitmap is better than the zoom out bitmap when it display on Android device.
.9.png is recommanded. It can use only in drawable folder.
if you want to reduce apk size then i will suggest you to place images on server and call them using RestApi. after getting all the json data by calling RestApi you will get the imageurl.
here is the link
Picaso Image Loader
you can load image on ImageView from url by using Picaso Image Loader. all the details are mentioned in link.
Leave Eclips and Start with Android Studio will provide this facility.
You can use the 9 patch.
Useful links :
http://radleymarx.com/blog/simple-guide-to-9-patch/
http://developer.android.com/intl/pt-br/tools/help/draw9patch.html
http://developer.android.com/intl/pt-br/guide/topics/graphics/2d-graphics.html#nine-patch
Put the Image in Drawable Folder. It will use the Same image for All Devices. But Quality will vary for Devices to device. The image may get Blur as Big Screen increase the width and height of images.
Lets consider the following, I have an app with several dozen photos I want to show the user at any given time.
Right now I'm creating multiple files for each image, sizing them for different screen sizes and storing them in their respective drawable folders.
It's increasing the size of my app dramatically.
So here is my question: Is it possible to store the images on a server and use an image library like Picasso, Fresco or something else (open to anything) to fetch that image and scale it down for the device it's running on without risking running out of memory?
I'm worried that fetching a large image, loading it into memory and then resizing it will cause the same problem as trying to display it on older devices with little memory available to them.
You can write methods to request different images sizes from your server based on client info. Just write a method to measure the screen size and then request the appropriate image based on a URL endpoint (like http://myimageserver.com/images/ldpi/image1.png).
You can do optimization post-download, such as scaling, before saving the image to a local file store.
Using a reputable image loading library is a valid method (my own favourite is Glide).
The answer to your question really depends on the number of images you want to show! If there are lots, then yes storing them on a server is probably best, but also the most time-consuming and expensive (both in time and money).
Your other (easier) option is to keep the originals in the assets folder, and use your image loader to scale and load them for you. The correct path for an image in your assets folder is file:///android_asset/your_image_here.jpg. This way, you're only keeping one version of each photo in your apk and they'll load much faster.