Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App Creating the Screen Layout Editing a Layout File

Aundrea Choe
Aundrea Choe
700 Points

I have CustomView rather than Relative Layout under Device Screen

Hi. I currently have Hello World coming out on the screen, but when I am on activity_funfacts.xml, my DeviceScreen has Custom View. My code looks like this:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="practice.funfacts.FunFactsActivity" tools:showIn="@layout/activity_fun_facts">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!" />

</RelativeLayout>

Do you have a layout called content_funfacts?

Aundrea Choe
Aundrea Choe
700 Points

Yes. The code in contents and activity seem to be flipped

2 Answers

Daniel Rothmann
Daniel Rothmann
8,625 Points

In Android Studio 1.5.1 I had to start over and choose an "Empty Activity" when creating the project instead of the "Blank Activity" which seems to have changed in layout and functionality since Ben made the course.

Aundrea Choe
Aundrea Choe
700 Points

Thank you. But then there is no contents_funfacts.xml. Is that okay for the rest of the tutorial?

Hey! The contents_funfacts.xml is just used to separate the content(file name says that) from the rest of the layout. You can either use that content_funfacts.xml file and put all the code Ben puts in the other xml file in your content file.

If you don't have that content xml file that's no problem. You can still use the regular xml file. Have a look at the activity xml file and you'll see an include statement that includes the content xml file. So it is just outsourcing the contents of your layout to a different file.

Hope I was able to help!