Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Lists and Adapters (2015) Standard ListViews Adding a Gradient

Louis Sankey
Louis Sankey
22,595 Points

how 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
STAFF
Ken Alger
Treehouse Teacher

Louis;

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
Louis Sankey
22,595 Points

Hi 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?

If 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
Louis Sankey
22,595 Points

Thanks, 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.