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

Android Build a Simple Android App Creating the Screen Layout Adding a Button

placing widgets

Hi, I can't seem to be able to place my widgets as well as you did in the lesson... My textView isn't having any of that center layout story it keeps wrapping itself around the corner and my button can't position at the bottom without dragging the text out the screen... how can I fix this or maybe use an un-relative layout so that anything could be placed anywhere? Thanks.

Ben Deitch
Ben Deitch
Treehouse Teacher

Hey Ariel! Could you post your layout XML file?

Sure, Ben, here it is:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" 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="therabak.myapplication.MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Fun Facts"
    android:id="@+id/textView2"
    android:textSize="24sp"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="151dp" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_marginTop="265dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true" />

</RelativeLayout>