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

Eniolal Oladipo
Eniolal Oladipo
1,151 Points

color code; what did I do wrong here

what did I do wrong here

activity_main.xml
<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" />

</RelativeLayout>

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

When you're doing hex color codes, they should not be preceded by @android:color/ - it should just be #fff092b0 as a string.

Rebecca Rich
PLUS
Rebecca Rich
Courses Plus Student 8,592 Points

There are a list of System Color Constants: https://developer.android.com/reference/android/R.color; which is what @android:color/white is based on. This should work for the first part of the challenge.

The second part asks you to use a HEX color format instead of the System Color Constants to set the background color for the RelativeLayout, so you just need to replace "@android:color/white" with "#fff092b0" which represents a dark pink color. Android supports the following color format: "#AARRGGBB" where AA represents the alpha, in this case 100% represented by FF, and "RRGGBB" is the standard HEX representation for dark pink or #F092B0". Here is more info on color codes: https://stackoverflow.com/questions/15852122/hex-transparency-in-colors