Welcome to the Treehouse Community
Looking to learn something new?
How to change background color and text in challenge task 1 of 2 of Android Dev?
Android Development Challenge task 1 of 2
Daniel Hartin18,106 Points
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.
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.
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
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.