Welcome to the Treehouse Community
Looking to learn something new?
Oscar Acevedo8,240 Points
Can't drag elements on the design tab
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>
Hi 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.