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

Change Android screen background to dark pink

Can someone tell me what's wrong with my code to change the background color? <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/#fff092b0" >

<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Treehouse loves me!" android:textColor="@android:color/white" android:textSize="72sp" />

3 Answers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Stephen,

Change "@android:color/#fff092b0" inside RelativeLayout to "#fff092b0".

android:background="#fff092b0"

The android prefix should only be used when you're accessing certain system colors likwe "white", "black" etc.

Grigorij

Thanks! That worked, but why are system colors so different? You mean I can't say android:background="#ffffffff"?

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey there,

android:background="#ffffffff"

would work fine. To use the system white color you need:

android:background="@android:color/white" 

I think that you are referencing to a system resource variable by typing @android:color and "white" is the name of the system resourse of the color #ffffffff.

Thanks again! This is helpful.

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

hey you are welcome !

See you in the forumm !

G