Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRifqi Fahmi
23,164 Pointsdrawable can't have subdirectories ! Android studio 2.1
In this video Ben Jakuben place the images in several drawable directories that nested inside the res directory. But in my android studio 2.1 software there are two directories called mipmap and drawable in the res directories. I have read some references that you should place the icon in mipmap folder only and the rest placed in drawable folder, but drawable can't accept subdirectories.
So my question is how to place the images with the different resolution in drawable directories that can't accept directories. If i place it inside the mipmap folder can I access the image with method like this:
getResources().getDrawable();
Cause Ben will use it in the next video at "Loading the first page" section minute 04:57
Thanks :D
4 Answers
Ozhan Saat
Courses Plus Student 4,002 PointsIt might be that you're viewing the project in Android view. If you are, changing it to project view will show you all the sub folders.
Ozhan Saat
Courses Plus Student 4,002 PointsIt's easier to understand if you can see whats going on for yourself.
While in project view, inside res, create five new folders (if they are not already there) drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi
Put the correct drawables into the corresponding folder. Switch between project view and android view to see how the drawables are listed. With the drawables in these folders you can use getDrawable.
Rifqi Fahmi
23,164 Pointshmmm maybe you need to see this http://stackoverflow.com/questions/1077357/can-the-android-drawable-directory-contain-subdirectories
Ozhan Saat
Courses Plus Student 4,002 PointsProject view shows the full project structure while android view is supposed to be a simpler view to navigate and use.
Rifqi Fahmi
23,164 Pointsbut why i can't acces the file inside the subdirectories for src attribute??
Ozhan Saat
Courses Plus Student 4,002 PointsThats why when you create the different drawable folders (mdpi, hdpi, xhdpi etc) you create them in res and not in drawable. Then you can access the images by calling getDrawable or @drawable and the right image size will be used for the screen size.
Rifqi Fahmi
23,164 PointsRifqi Fahmi
23,164 PointsI can see the folder i make in drawable folder in project view. But why i can't see it in android view ??