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 a Simple Android App Creating the Screen Layout Setting Colors

Change android background color

try to change the Android background color to darkpink with code fff092b0 I know I need to define darkpink somewhere, but don't know where. I read that you have to define it in strings.xml, but don't know the syntax.

<color name="darkpink">#FFF092B0</color> . . . android:background= "@android:color/darkpink"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <color name="darkpink">#fff092b0</color>

    android:text="Treehouse loves me!"
    android:textSize="72sp" />

Jordan Ernst
Jordan Ernst
5,121 Points

also should mention that you don't need to change any of the code already written. just worry about the one line labeled "android:background= "" <<<<<<<< this is what you need to fix. nothing else

2 Answers

Jordan Ernst
Jordan Ernst
5,121 Points

hey friend technically you are right, but you are also wrong. you would have to add it to your xml <String> although it is just asking you to set the color by a default hex value. so no name is required. just #fff092b0 is needed! happy coding :)

Mazen Halawi
Mazen Halawi
7,806 Points

add a darkpink color in styles (resources -> values -> styles) <color name="darkpink">#fff092b0</color> then you can reference it in your layout xml