before when I was creating a new project I was found this folders drawable-hdpi,drawable-mdpi, drawable-xhdpi, and drawable-xxhdpi. but now they are all gone!
is there any explanation of what happens?
and where we should put our images?
This is perhaps because they will add an Gradle plugin that converts SVGs to PNGs during build (as mentioned in this IO talk). The idea is that you will only need to have a single SVG instead of multiple PNGs for various densities (an thus, only one drawable folder). You can still create the folders and use PNGs.
The Gradle plugins for SVG conversion by Google has not been released yet, but you can use Victor or a similar plugin if you already want to use SVGs for your drawables.
You should read Android Blog
you can just create drawable-xhdpi.
I just give answer here
read and if any problem ask.
I wasn't aware that Android Studio ever provided these dpi dependent drawable folders for the built-in default project scaffolding, and indeed, why should they?
Are they supposed to guess that you're going to support each and every one of these resolutions? Perhaps all your graphics will be vector graphics? Perhaps you only target low or high resolutions?
Also, the DPI modifier is only 1 of the possible modifiers you can attach to a resource folder. You can also add locale, screen width / height, mobile country code and many more. Should Android Studio create a folder with each of these options, along with every possible variation? You'd end up with thousands of folders which you'd likely never use.
In addition, creating a folder with no assets inside it is a big problem when you start synchronising your code using Github or something similar, and creating every possible folder with default assets inside seems like a huge waste.
I think the best approach here is to create any resource folder you need when you need it. Google leaves this decision to you.
Also, important: There is no XDPI or XXDPI folder - it's XHDPI, and XXHDPI
Check in your project section, Not in android section, If they gone just simply create them
Related
With older versions of Android Studio, all of the drawable bucket folders were created by default (i.e. drawable-mdpi, drawable-hdpi, etc.). In newer versions of Android Studio, it only provides drawable and drawable-v21. Why is that?
Is there a reason that Android (in its infinite wisdom) no longer gives you the separate bucket folders?
Just to note, I know you can just add them manually, but I want to make sure there isn't some new best practice reason to not use those folders anymore.
Thank you to everyone who tried to help. You helped me reach the final answer, but no one solution was quite right. #user3137702 was probably the closest, as it IS related to the whole move to vectors/SVGs. I couldn't find a definitive answer, like something directly from Google (although I imagine it is out there), but from what I've gathered from a bunch of articles, there is probably a reason they are doing this.
For starters, it looks like this started in Android Studio 1.4. I am in 1.5 right now. It seems that Android is moving in the direction of no longer needing you to create your own density folders (i.e. mdpi, hdpi, etc.) for drawables (mipmaps is different, so please don't confuse that with what I am talking about). As of Android Studio 1.4, it will take the SVGs you put in the regular drawable folder (as in not the v21 folder), convert them to PNGs, and place them in auto-generated density folders for you during the build sequence (so Gradle does this for you, essentially) for all versions older than API 21. For 21 and up, SVG is supported different, which is a whole other topic. But this essentially makes SVG support backwards compatible all the way to API 1!!!
HOWEVER, there is a BIG catch. This SVG conversion is not always as successful as you might hope. It only supports a subset of SVG files, so depending on how you save it (i.e. what settings are applied when saving), it may not render properly. Even commonly used settings, such as gradient and pattern fills, local IRI references, and transformations are NOT supported (yet). If you are working with SVG files that you didn't generate, you will likely have problems importing them. If you or someone you work with directly generates them, you may have to experiment with how you save the files, and you should test builds often on older versions of Android to make sure it turned out as expected.
To import SVGs into Android Studio 1.4+, follow these simple steps:
Right-click on the res/drawable folder
Select "New"
Select "Vector Asset"
At this point, you can select a "Material Icon", which works
really well, and there are a bunch of beautiful "free" icons you can
select from. For indie developers, without icon design support,
this is nice!
OR - you can select "Local SVG File"
Then choose an SVG from either option with the "choose" option. WARNING: This is where it could possibly go wrong, if the SVG you import isn't saved properly.
Hit "Next"
Verify it is saving in the right place, and then Click "Finish"
At this point, it is reference-able with: android:icon="#drawable/ic_imagename" (using your image name instead of ic_imagename, of course)
#CommonsWare's response was very helpful in leading to the right solution, but from what I saw, generating several variations of new projects from different template and version support settings, there wasn't any way to actually have the old density folders get auto-generated. There is definitely more going on here than just a different template-version selection. But as he said, depending on what template/version you select, you may end up with a different set of those two drawable folder types. But specific to my question, Android Studio does seem to be putting an emphasis on this new approach of not creating your own individual drawable density folders at all.
It's pretty cool, imo, but it still needs some work. In practical terms, I will likely still need to add the drawable density folders to support all the images I work with, until this mechanism gets a little more supportive of all types of SVG renderings.
And one more tidbit - Because this is all handled through Gradle (the actual generation of the density folders) you can add build settings through the flavor mechanism to limit which density folders you want to generate. So if, for example, you feel mdpi images have reached the end of their usefulness for your particular user base and would like to leave that size/density out of your app to shave a couple MB off the app size, you can set that in the Gradle build flavor.
In android project there are multiple folders, I know you can simply override these with one 'Drawable' folder.
My question is: When people download my app, will it take up more room if I have manually catered to all the different Drawable folders instead of just overriding them with one?
yea, but your app will be slightly slower, cause android has to re-size the images (whereas if you have different folders it uses the respective images)
Yes, different Drawable is for different dpi based device screen and its part of APK.
When you download APK then even drawable is also part of it and it gets stored on device and it does take space.
Different Drawable folders in android directory is for supporting different screen sizes. for better UI experience you should put drawables in appropriate folders.I think you should have look into it before proceeding further Know android project directories
I see three folders within my eclipse project drawable-hdpi,mdpi,ldpi
Do I need to put images in all three of these folders?Or can I just use one of them.My images
seem to scale fairly well.I do not want to have duplicate images if it is uneccessary.
I guess what I am asking is will the app be able to find my images if I just use one of the above mentioned folders?
Technically if you drop them in mdpi, I believe all devices 1.6 and above will find them. However, if you support below 1.6 devices you'll need to duplicate the drawable-mdpi resources and call it just drawable.
Yes it will find the Drawables regardless of which directory you use. You can also just have a drawable directory if you don't plan to support different densities.
I'm newer in android development. And after using eclipse about 1 month... i hate this. I've setup NetBeans IDE for android development. It's fast, it's looks like cool and i like it. But have one trouble. I cant find how to use drawable resources (just like R.drawable.icon) :( . Can anyone help me?
PS: sry 4 my english
Use the file browser on the left hand side in NetBeans to open
YourProjectName -> res -> drawable and you will find your drawable files here. Also, Android provides different drawable folders to support multiple screen sizes, i.e : drawable-hdpi, drawable-xhdpi, drawable-mdpi. These are great if you wish to support your app on multiple screen sizes and don't want to scale the images using code (it makes them look ugly). Then you can just place different sizes of the same drawable image in these folders and android will automatically figure out which one to use!
Your English is quite decent in comparison to some of the drivel people post here.
This is simpler with updated version of NBAndroid (including NBAndroid Extensions). See some comments at http://www.nbandroid.org/2013/04/tuning-hyperlink-navigation.html
What is the difference between the three drawable folders in the res folder in the project hierarchy? If I have an image to put into a folder, which folder do I put it in?
I am going to take a guess that "the three drawable folders" are drawable-ldpi, drawable-mdpi, and drawable-hdpi. In that case, if you stick with all of those folders, you need to put one image in each, sized to match the indicated screen density. This is discussed in the online documentation as well as this blog post. You can find a set of sample projects showing use of different drawable resources based on screen density here.
If you are just starting out in Android development, you can get rid of all three of those directories and create a single drawable directory, putting your image in there. Eventually, though, for a quality application, you will want to test your images on different devices/emulators with different screen densities, and possibly have different images for each density to improve the look of your app.
Here is a reference to multi device options.
As said by #CommonsWare, you don't need to put resources in anything but res/ layout/ or drawable/ but if you want your program to have a better experience on multiple devices with different screens / density / languages you may want to consider that you have that option.
Also interesting, though not specific to images, is how android handles resources. It gives them a load order, where more specific means it'll get picked over less specific.
For example, you have three String values in strings.xml in your values folder. You also have one specific string in a folder called values-en. When android opens your app and your locale matches en, it will load two defaults from the values folder and the third, more specific string, from values-en. If your locale is ru, it will just use the default instead because you have no values-ru folder.
The same is true for images. If android can't find images for your specific screen variant, it will use defaults from the drawable folder.
In my opinion it's good practice to have default values/images in your generic folders like values/drawable and specific values/images in specific folders. This way both current and future devices will at least have a way to display your content until you can provide specific versions.