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!

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

how do you do this?

We just saw how adding a Button generates the XML for us. Now let's write the XML by hand. Start simple by adding a Button element. Copy and paste the TextView element and just change 'TextView' to 'Button'.

http://teamtreehouse.com/library/build-a-simple-android-app-new/creating-the-screen-layout/adding-a-button-2

1 Answer

Harry James
Harry James
14,780 Points

Hello,

All you need to do is write:

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

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

Creating a TextView or a Button are exactly the same in XML so, all you need to do is copy the TextView object then paste it but, replace its type with "Button" instead :)