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 (2014) Creating the Screen Layout Setting Colors

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

How do I change the RelativeLayout background color in the activity_main.xml Challenge Task #2? I don't understand.

I have tried and tried and tried and even watched the video multiple times, but they only show how to do it in display view, not xml.

activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_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>

1 Answer

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

You should only need to use "android:background", not "android:layout_background".

Also as the "parameter" you only need to give the hexadecimal value of the color that you want (don't forget the '#' sign).

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

lol Sorry man, these simple things hard for me. I get lost with all of this because I've been to like every site for coding.. or at least a lot of them. I really want to create an app soon but when they start spitting out these terms, it just gets confusing. I don't know how I'm ever going to be proficient at any language, honestly. Still trying, though.

Jon Kussmann
Jon Kussmann
Courses Plus Student 7,254 Points

It takes a lot of time to get used to, programming language is another language, after all. You'll learn more as you struggle through it. :P

One way you could get used to that sort of issue is use the design tab to get things how you want it to look and then study the xml afterwards (i.e. change the background color in the design tab, then see what the xml looks like).

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

That makes a lot of sense. Hey, thanks for the help and encouragement. I appreciate it.