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 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,441 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