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 trialOscar Acevedo
8,240 PointsCan't drag elements on the design tab
Hello everyone!
So after creating my project with the empty activity and changing the layout to RelativeLayout, no matter what, the TextView is always on the top left corner of the screen, I can drag it but it goes back to the corner. This is how the xml looks.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Did you know?" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</RelativeLayout>
Thank you!
1 Answer
Lauren Moineau
9,483 PointsHi Oscar. I'm not sure what layout you have in mind (i.e views side-by-side, under one another...) but with a RelativeLayout, you are supposed to tell your layout how the views should be positioned relatively to one another.
So you should give each of your views an id, then attributes explaining what its relative position to the parent or the sibling(s) is. Have a look at the official documentation for help.
Happy coding :)
Edit: Otherwise, just click on the magnet icon in the Layout Editor) so that it's not crossed out to activate Autoconnect and the relative layout attributes will be added automatically for you as you place your views around the layout.