I just moved Eclipse Based Android Project to AndroidStudio.
And I figure out drawable folders got combined.
My question is...
How can I change image(xhdpi) to image(hdpi)
And How can I add more image and Make folder base image.png.(like this screenshot).
If you don't see a drawable folder (xhdpi to hdpi) for the DPI that you need, you can create it yourself. There's nothing magical about it; it's just a folder which needs to have the correct name.
Curtsy Yole Sir
Change image folder (for example xhdpi to hdpi) is possible via right mouse click > refactor > move. And now you can select subfolder.
Related
I'm new to Android programming. I was working for UI design stuff using Adobe XD and I exported the stuff I created to Android Studio. I was following this tutorial. And I was trying to use the stuff in drawable folders I created. (like drawable-hdpi) But the stuff that is stored in these folders doesn't show up. Only images that are stored in drawable folder show up. What am I wrong with this?
I mean the files doesn't show up as a suggestion and on this list.
This is the normal behavior.
Folders like drawable-hdpi or drawable-mdpi should contain the same as per name drawables as the drawable folder but with different resolutions.
When you choose a drawable in code or resources you see the drawables contained in drawable folder but at run time depending on the resolution of the emulator/device another drawable with the same name as the original from the other drawable-xxxx folders will be used.
In the dialog in the image you posted if you click on project you may see drawables from the other folders and choose them, but it's always a good practice to use the Drawable folder too.
Like in recent versions we used to find drawables-ldpi, drawables--mdpi etc but these don't exist now. Should i create those or just copy them in the drawables folder without these sub folders?
If you want a drawable folder for the DPI that you need, you can create it yourself. There's nothing magical about it; it's just a folder which needs to have the correct name. for example drawable-hdpi ,drawable-xhdpi,drawable-xxdpi,drawable-xxxdpi etc.
u can just paste your file or anything no need of hdpi and mdpi folder in drawable.
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?
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..!
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
I m trying to integrate different image size in my app but the problem is that in Android Studio there are not the drawable-Idpi,mdpi,hdpi,xhdpi folders.
I ve checked already other threads and the answers were that I just need to skip into the Project view instead of the Android one. But the results are the same. There is just one generale folder called drawable
And if I try to add another resource folders the drawable is missing.
Just create a new folder:
Right click 'res' folder --> New --> Android Resource Directory.
In the wizard, select drawable as 'Resource Type'. And then 'Density' from the resource qualifiers.
With regard to the 'mipmaps' folders, Android now prefers app icons in these folders because it can use an icon in a different density to the screen density.
More about mipmaps here: http://android-developers.blogspot.de/2014/10/getting-your-apps-ready-for-nexus-6-and.html
I had the same problem before.
I fixed it by downloading an icon that i wanted from http://www.icons4android.com/
now this site provides all the drawable-Idpi,mdpi,hdpi,xhdpi folders for download for each icon they have, I just highlighted all the drawable-Idpi,mdpi,hdpi,xhdpi folders, copied them, and then pasted them to android studio res folder.
(I did this in android view)
I hope this helps
You can create folder same as drawable, drawable-hdpi, mdpi, xxhdpi ... etc
Its look like
But when you see source code using
Add images in draweble its ask you in which folder you want to add(copy n past images in studio)
You can directly creat folder in res its also work...
I'm an Eclipse developer and recently switched to Android Studio.
I know that "drawable" folder is where I must upload all the images I'm going to use in my Android project but, what happens with the image sizes? In Eclipse there are different folders for each size (xxhdpi, xhdpi, hdpi...)
What method should I use now to get the best compatibility with images and devices?
Thanks.
In Eclipse there are different folders for each size (xxhdpi, xhdpi, hdpi...)
They are there in Android Studio too. The Android Tools team kinda hid them.
If you look just above the project explorer tree thingy on the left, you should see a drop-down, one that probably says "Android" right now:
That is the Android project view, one that gives you a somewhat synthetic look at your project, collapsing things like resource sets and sourcesets to hide those details.
Eclipse users will probably be happier with the classic project view, which you get by clicking that drop-down and switching it to "Project":
This works much like Eclipse's Package Explorer, where you get an actual filesystem view of what's going on, complete with resource set directories.
It's all the same stuff on the filesystem, but the Android project view masks it a bit.
Right click drawable -> New -> Image Asset -> Asset Type: Action Bar and Tab Icons. Image file: image_path, Resource Name: how_youre_image_will_be_called -> Next -> Finish
Done
This will add 4 different sizes of your image so that it will fit depending the device size (phone, tablet...)
You can also ctrl+c -> ctrl+v to drawable folder and pick the size you want (mdpi - phones, xxhdpi - tablets...) but it would not resize by devices type
Studio is generate image klasor automotacly.
just suld make like this.
ic_launcher 36*36
ic_launcher 48*48
and other image resizes.
But one thing changed.Now ldpi is dont create.
The easiest way is to use Resource Manager, it allows to upload our images from Android studio itself and then resize it with each density