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

tsering namgyal
tsering namgyal
2,830 Points

how do i change the text color to white in xml design?

i tried adding both the background and text color on textview design.But i could nt still get it right. Pls need your help

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/white" >

  <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" />

</RelativeLayout>

1 Answer

andren
andren
28,558 Points

Text color is set using:

android:textColor="COLOR"

But don't forget that to pass the task you have to set it to the exact same color as the background of the relative layout is set to, which is "@android:color/white".

try to set the color as hexadecimal like #ffffff instead of using the @android:color/white

andren
andren
28,558 Points

Benjamin Dahlhoff: This task is setup such that "@android:color/white" is the only accepted answer. If you set it to white in some other way including "#ffffff" it will give you an error message saying:

Make sure you use the white value exactly as set in android:background.

That is why I specified in my answer to use the "@android:color/white" color value.