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 trialtsering namgyal
2,830 Pointshow 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
<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
28,558 PointsText 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".
benjamind
6,442 Pointsbenjamind
6,442 Pointstry to set the color as hexadecimal like #ffffff instead of using the @android:color/white
andren
28,558 Pointsandren
28,558 PointsBenjamin 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:
That is why I specified in my answer to use the "@android:color/white" color value.