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

Now let's add a Button element in XML. Hint: Copy and paste the TextView element and change 'TextView' to 'Button'.

Now let's add a Button element in XML. Hint: Copy and paste the TextView element and change 'TextView' to 'Button'.

activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</RelativeLayout>
<Button

    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

1 Answer

Mark Filter
Mark Filter
32,718 Points

Your Button tag must be inside the RelativeLayout tag. Currently, its conveniently sitting outside and getting lonely.

juan lourido
juan lourido
460 Points

can you do like a demonstration cause I'm still lost