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 trialCodrin Postu
8,022 PointsAll the items I drag and drop on the layout just go to the top left corner
Is there anyone that could explain why this happens? I don't get the blue dotted lines or arrows when I use RelativeLayout and I don't know what setting I am missing.
I can edit it manually in XML file but I am curious why for Ben it works just by dragging and for me it doesn't
Here is what it looks like: https://i.imgur.com/vsxeY13.png
Edit: I managed to get them to be in a certain position on the screen but I do not have the dotted lines or centered lines to help me align them properly. Is there a setting to turn them on?
3 Answers
Lauren Moineau
9,483 PointsHi Codrin. I think that when that video was recorded, RelativeLayout was the default root layout. Now it's ConstraintLayout and afaik you no longer get these guidelines by default with the RelativeLayout.
You can try the following in the Layout Editor:
- Click on the magnet icon (next to the eye icon, top left, next to the Palette menu) so that it's not crossed out: this turns on Autoconnect.
- Drag a new view onto your layout.
- You will see 2 grey lines (1 horizontal and 1 vertical) coming out of that view as you move it along the layout (along with dimensions). They're 2 default constraints to the parent layout.
- Click on the (red) dot on the view frame to remove both constraints. At this point, your view should be back at the top left corner
- Now as you move your view again around the layout, you should see the horizontal and vertical guidelines appear in bold green. Release your view when you're happy with its position.
- Repeat with the next view (remove the 2 default constraints). You will see thinner green lines to help you align that new view to the previous one too.
I hope this helps :) If it's unclear, let me know and I'll include screenshots.
Malcom T.L Musuma
11,363 PointsHello, i cant figure out the red dot in the view frame. Can you send a screenshot
Ted Trollope
417 PointsIt's on the 4 dots surrounding the frame , they start blue but when you mouse over them they turn red
Gedeon Christ
194 PointsThanks a lot. I had the same problem but not it is working.
Lauren Moineau
9,483 PointsI'm glad it helped :)
Codrin Postu
8,022 PointsCodrin Postu
8,022 PointsRight now I changed to ConstraintLayout because that has the snapping lines and I did click the magnet icon. It works now. I will wait to reach for the video where it explains the difference between them more in depth. Which one is recommended to be used though? Relative or Constraint?
Lauren Moineau
9,483 PointsLauren Moineau
9,483 PointsGreat, Glad you got it working with Constraint. I would advise you to go with ConstraintLayout now. It's got everything RelativeLayout has plus much more :) Here is a nice Google codelab if you'd like to practise a little.
Jared Brunk
533 PointsJared Brunk
533 PointsThank you, this was very helpful