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 trial
Samiruddin Syed
3,136 PointsAndroid Eclipse Problem
(http://imgur.com/p25T0wB) (http://imgur.com/y5mOMt0)
The second image shows how the green dotted lines appear when placing a Plain Text field in the layout.
But in the first image, Im not able to get those Green dotted lines as I got them in the second image.
Note : The change of file names in the first and second image.
In Fragment_Main.xml, the dotted lines appear correctly but in activity_login.xml, the dotted lines do not appear.
Im having problems placing the buttons and other things when these dotted lines aren't appearing.
Please Help.
4 Answers
Samiruddin Syed
3,136 Pointshere is the XML code for "activity_login.xml"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.syedsamiruddin.ribbit.LoginActivity"
tools:ignore="MergeRootFrame" />
and here is the code for "fragment_login.xml"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.syedsamiruddin.ribbit.LoginActivity$PlaceholderFragment" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
Ben Jakuben
Treehouse TeacherThis is most likely due to slight differences in the default layouts of the Fragments and Activities. If you switch to the XML view of each you'll notice that they are different, which causes this different behavior in the graphical editor.
Can you copy and paste both layouts in here? I can explain any differences.
Samiruddin Syed
3,136 PointsBen Jakuben please help me out here
Samiruddin Syed
3,136 PointsBen Jakuben Thank you for the help. I downloaded the files from the video page and used them.
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherOkay, sorry for the delay! The Activity layout is using a FrameLayout, which is a super simple box layout that doesn't do anything special. All it does is hold a container for the Fragments, i.e. a ViewPager or something else.
The fragment layout is using a RelativeLayout, which lets you position things relative to its borders, center, or other items inside it. That's why you can get the dotted lines and such.
These fragments are now included by default when creating new Activities in Eclipse, which is obviously different than the videos. You can either continue with the fragments or refactor your code to remove them and continue with a regular activity, just like the videos. For step-by-step instructions on how to remove a Fragment, check out this Forum post. I will add notes to the video page as well.
If you decide to just work with the Fragments, you can make your changes inside the fragment_login.xml file and make the corresponding code changes inside the
onCreateView()method of the PlaceholderFragment instead of theonCreate()method of the Activity.