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 trialMUZ140118 Cathrine Makuya
10,300 Pointsstage 1 challenge 1
In the layout file below, align the EditText to the top of its parent (the RelativeLayout). Hint: Check the current code for a similar example.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/captionField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:hint="Enter a caption" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/grumpy_cat" />
</RelativeLayout>
3 Answers
Logan R
22,989 PointsThis one should be easy enough ;)
Lets look at the editText XML:
<EditText
android:id="@+id/captionField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:hint="Enter a caption" />
We can see a property that talks about alignment and it's parent and a left/right/top/bottom
android:layout_alignParentLeft="true"
So all we need to do is copy it, create a new line below and paste it in and slightly change it to our needs
android:layout_alignParentTop="true"
And there we go! To complete this challenge, just insert the line above in the editText XML slot and the task will complete :)
If you have any other questions about the next tasks in the challenge, feel free to post them below or as a new question.
AHMED ELBADWI
979 PointsIt should be easy for people with a background in XML.
Neil Gordon
8,823 Points<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
<EditText
android:id="@+id/captionField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:hint="Enter a caption" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/grumpy_cat" />
</RelativeLayout>```
here is what worked for me
MUZ140118 Cathrine Makuya
10,300 PointsMUZ140118 Cathrine Makuya
10,300 PointsThanks it worked
Logan R
22,989 PointsLogan R
22,989 PointsNo problem :) Glad I could help!