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 trialJeff Domitrz
223 PointsTrouble aligning "Text View" widget to the center of the android screen.
When I click and drag the "text view" widget into the graphical layout, much like the video, some green cross hairs appear. However when I release the mouse button in the center, the "text view" widget returns to the upper left corner of the layout.
I noticed that in the video the xml used is:
android:layout_center_InParent = "true"
Where as mine is displayed:
<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:gravity="fill" 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.example.crystalball.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="TextView" />
</RelativeLayout>
I've tried editing the xml but it doesn't seem to change the position of my "text view" widget or my "button" widget. Any idea what I'm doing wrong? Many thanks!
-Jeff
1 Answer
Jeff Domitrz
223 PointsFixed. In the xml there was the following command:
android:gravity="fill"
After deleting this command the problem was solved.