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>