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

How to change background color and text in challenge task 1 of 2 of Android Dev?

Android Development Challenge task 1 of 2

2 Answers

Daniel Hartin
Daniel Hartin
18,106 Points

Hi Beau

Just a little advice:

It may be beneficial in future if you are struggling with a particular code challenge to reference the code challenge and posting any code you have so far, it does make it harder to guide you if I don't know what there asking you to do.

Challenge 1

Okay so the challenge is asking you change the textColor attribute in the TextView. I have added the line of code you need below (android:textColor="@android:color/white") this line uses the built in colors available to you courtesy of android. You could use a hexadecimal color code and that would be fine too.

Challenge 2

Okay in challenge 2 you are applying the same logic you did to edit the color of the TextView in challenge 1 only to the entire background color. This time however we aren't using a built in colour, we are defining our own color using a HEX format. We do this by using the tag (android:background="#fff092b0"). You could use a built in color easy enough if you wanted by using (android:background="@android:color/white") and that would work fine too.

The code you need for both challenges is below, or try it yourself using the above information.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#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:textSize="72sp"
    android:textColor="@android:color/white"/>

</RelativeLayout>

Hope this helps

Daniel

Hey Daniel, Thanks in a million. The code works and I really appreciate with your advice and it really motivates to work hard learning this track.

Beau.