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 trialLouis Sankey
22,595 Pointshow to access main drawable folder
I want to create a gradient by adding a new drawable.xml file like it shows in the video, but for some reason my directories are not arranged in the same way it shows. Directly under the res directory I have all of the sub drawable resource directories such as drawable_hdpi, etc. But I have no overarching drawable directory. I tried to refactor but I could not figure out how without leaving any errors. I tried creating a new drawable directory under res and then tried dragging the directories in. I tried the two options that it gives: the "move packages option" as well as the "move directories" option. I am also confused because when drawable resources are referenced in my xml code in other places they are referenced as android:src="@drawable/degree" for example. Do I have an overarching drawable folder that I am somehow not seeing? Any help would be appreciated, thanks.
4 Answers
Ken Alger
Treehouse TeacherLouis;
I had the same issue as well when trying to create the gradient. In the Project window of Android Studio, there is a drop down that gives a few options like Project
, Packages
, Android
, and Scopes
. When I switched between Project
and Android
(or vise-verse), I was able to create the drawable
directory easier.
Post back if you are still stuck.
Ken
Louis Sankey
22,595 PointsHi Ken, Thanks for you reply. I see the drop down you are referring to and tried toggling the project view and other views, but I was still unable to refactor in the right way. I don't know why in the first place I have a different file structure. I checked out my other projects and they are all the same, with no overarching drawable folder like in the video. I tried creating a completely new drawable directory named drawable and adding the bg_gradient to it, but android studio was unable to render. I have a hunch that when I add a new drawable folder and try to refactor it is making my file structure @drawable/drawable/whatever. It seems like I already have a drawable folder, but I am unable to see it in the file structure. Is there any way I can add a screen shot?
johnsmith74
1,858 PointsIf you switch to the Project view, then right click the 'res' folder, you can create a new Resource File, set its type to drawable, and Android Studio will create the drawable folder for you.
Louis Sankey
22,595 PointsThanks, I was able to create a new drawable folder and add bg_gradient in the way you mentioned. I actually found out that the problem I was having was that I needed to clear caches and restart android studio. I was having a rendering problem and I kept thinking it was because of the file structure, but apparently android studio needed to be restarted and the problem went away. Still, thanks for the help.