how to use one size of image in android - android

I am using more than 400 images in my android application each of different sizes placed in
respective drawable folders(ldpi, mdpi, hdpi, xhdpi, xxhdpi).
This makes my app heavy.
Is there any way to use only one image size for all the android devices of different screen
densities?
I have used 9-patch images but it looks very blurred especiallyin ldpi devices.
I have tried to use SVG but getting error- java.lang.UnsupportedOperationException.
I dont know whether I am going wrong with adding SVG jar file in my android application.
Please provide me the steps for adding SVG jar file in my android application.
Please let me know if there is any solution other than 9-patch and SVG that I can use for
making android application.

You can make a single drawable folder and store all your images in the one folder.
res/drawable

store all your xxhdpi images in xxhdpi drawable and no need to store mdpi,ldpi,hdpi images in respective drawable folders.

Related

How to store the all jpg pictures that I've used in program

I want to implement an art game android application in Android Studio. But I'm confused about how to store the pictures? There will be 100 or more pictures of art works in game. The idea came to my mind is to minimize the sizes of pictures and adding them in drawable folder. Is there any efficient way to do that?
Thanks
First of all use TinyPng to compress your images without loosing ANY quality, I said ANY and I mean it.
and second don't put them in drawable because android will increase there sizes when you will generate signed APK, instead you should put them in raw directory which you can create in res directory, like res/raw.
Raw directory works same as drawable and any files in this directory gets resource Ids just like drawables so you can access files in it just like R.raw.yourimage.
I work on applications which includes hundreds of images and this is the best approach I have used.
Hope it helps.
If you are concerned with the space the 100 images takes up you could use a tool like photoshop or similar so compress your images to desired size (publish to web in photoshop).
Other than that I dont see why you shouldnt just save them in a drawable folder.

Do I need to put my icons in both mipmap and drawable folders, if I am supporting older versions of android (before 4.3)?

There are many posts which suggest that you should use the mipmap folders for your app icons. This seems to have come in android 4.3
I intend to support older android devices (Android 2.3.3 and above).
I have:
minSDK: android-10
targetSDK: android-10
Does this mean I have to create drawable folders too ? What will happen if I put my app icons only in the mipmap folders and do not create drawable folders ? I only have a device with android 4.4.4 so I cannot test with earlier devices. What should I do ?
According to this post the mipmap folder are only to keep the app icons. The other images and icons used in application should be kept in associated drawable folders!
App icon(logo) should only be in mipmap folder. Placing the different size if images in the mipmap folder will show icons in every android phone. Drawble folder contain images which is used inside the app.
Short
You don't need to put app icon in drawable if you already have it in mipmap folder.

Android Drawable folders aren't detected?

How do the drawable folders work nowadays?
I used to be able to just add folders named drawable-mdpi and such to get image resources, but this feature has seemingly disappeared. Image assets doesn't allow me to add image assets that aren't icons without messing them up and manually adding the drawable folders I need doesn't work any more as android can no longer find the resources.
How does android look for drawables now and how can I add prescaled images to my projects manually?

working with assets folder or drawable folder

I am creating an app using android studio.
i created the assets folder and created sub directories under it for each activity i am using (each one has a different set of images).
But on the other hand i want to support multiply screen resolutions which as i read is supported using drawable folder's, also drawable doesn't support sub directories.
I am using API 19 at the moment.
Putting all the images in drawable folder will be a bug mass.
How can i achieve my goal of order in my images and supporting multiple screen resolutions
Thank you in advance
there are subfoldes in drawable. take a look at this http://developer.android.com/guide/practices/screens_support.html
The drawables folders allow you to save various resolution versions of an image into separate folders. The OS will choose the right asset based on the device screen density for you when you ask for #drawables/image_name. /assets is more like a normal file directory. In general if you pull from assets you need to handle resolution differences on your own.

how to load drawables from /drawable-hdpi instead of /drawable android?

When i run my app on android 2.3 emulator, without creating the /drawable directory, images are loaded from the drawable-hdpi directory.
But when i create the /drawable directory, images are loaded from the drawable instead of the drawable-hdpi directory. I have create the drawable folder to make my app to run also on android 1.5.
What should i do to load images from drawable-hdpi/mdpi/ldpi on android >=1.6?
The resources that are loaded are specific to the target that the application is being run on. If the phone is an HDPI qualified phone, then it will load those resources.. if its MDPI then it will load those resources...
You shouldn't be setting these directly, because this is handle specifically by the frameworks.
The rules used by Android to find the best matching resources at runtime are explained in this document.
Especially:

Categories

Resources