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,375 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".

Benjamin Dahlhoff
Benjamin Dahlhoff
3,849 Points

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

andren
andren
28,375 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.