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 trialJamaru Rodgers
3,046 PointsHow 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.
<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
Courses Plus Student 7,254 PointsYou 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
3,046 PointsJamaru Rodgers
3,046 Pointslol 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
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsIt 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
3,046 PointsJamaru Rodgers
3,046 PointsThat makes a lot of sense. Hey, thanks for the help and encouragement. I appreciate it.