tags:

views:

10

answers:

1

I am creating a few layouts with the root element being merge. inside the merge element i have a ScrollView containing a TextView. Here is the file:

<?xml version="1.0" encoding="utf-8"?>
<merge
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  <ScrollView
    android:id="@+id/scroll"
    android:padding="6dp"
    android:layout_below="@id/headingLayout"
    android:layout_above="@id/tabsLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
      android:id="@+id/aboutTxt"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
  </ScrollView>
</merge>

I am getting 2 errors: there is no resource to match the layout_below and layout_above names i have put in.

I have another layout xml file including very similar components, some of which also reference @id/headingLayout and @id/tabsLayout. Both of these XML layout files do not contain the component with name headingLayout or tabsLayout

Why is it that one layout file has no errors about these references and the other layout file does? What the crap am i doing wrong, the app will build and run like i expect, until i add this merge to another layout?

I have even tried copying the xml from the working layout file, to find that it gives the same errors, something must be wrong with my new layout file. I have tried cleaning, rebuilding, opening/closing eclipse..

A: 

Wow, this is a strange fix i have found for this. the layout i have given in my question above(the one giving errors) is named about.xml. the layout with no errors which also includes merge and references to other xml components is named home.xml. the xml file including the referenced components is named base_layout.xml.

in the eclipse Package Explorer under the layout folder, items are listed alphabetically. so the home.xml file came after base_layout.xml, and could therefore reference the components inside it. Since about.xml came before base_layout.xml, about.xml could not reference anything inside base_layout.xml.

so i just renamed base_layout.xml to aaa_base_layout.xml so it would be first, and all errors go away.

binnyb