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 trial

Android Build an Interactive Story App (Retired) User Input Introducing ImageViews

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

drawable 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

It 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.

https://developer.android.com/studio/projects/index.html

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

I can see the folder i make in drawable folder in project view. But why i can't see it in android view ??

It'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.

Project view shows the full project structure while android view is supposed to be a simpler view to navigate and use.

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

but why i can't acces the file inside the subdirectories for src attribute??

Thats 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.