I am very new in Android and I have the following doubts related how to handle images into my project.
I know that I have to put the images into the /res/drawable/ directory into my project.
To make order I have tryed to split up these images into differend subdirectory.
So for example I have created this subdirectory: /res/drawable/header/ that contains all the images related to the header of my application.
But when in the XML I do:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:scaleType="fitStart"
android:layout_height="250dp"
android:src="@drawable/header/carbonara"/>
Android Studio give me an error on this line:
android:src="@drawable/header/carbonara"
that say to me that: ‘/’ is not a valid resource name character
So in Android I really can’t create structured and well organized subfolder for my images?
Another doubt is related to the different version fo the drawable folder.
I know that I can create a structure like this:
res
drawable-hdpi
drawable-ldpi
drawable-mdpi
.............
.............
.............
where each drawable* contain a specific version of the same images having different pixel density.
Using Android Studio can I automatically generate these folder starting from the drawable folder (containing my original images) or have I to create these folder manually and manually change the pixel density using something like Photoshop?
2
Answers
If you want to create different version of drawable then change the view to project from android. then navigate to the Project name->app->src->main->res and create different directories for each screen density like hdpi ,mdpi etc. you can take reference from mipmap.
p.s. : For automatic scalling of drawables you can consider the using of svg
Link: Developer android link
You can Go through this Link –https://romannurik.github.io/AndroidAssetStudio/nine-patches.html
Here You can upload your images and generate images with different pixel density. Android Studio doesn’t support automation for Generating drawable images..!