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,426 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
PRO
Rebecca Rich
Pro Student 8,587 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