This is really more of a reference for myself than anything else. Point being I just spent about half an hour trying to figure out why my TextViews were not showing up in my LinearLayout for my Android application. What I was getting was the top level TextView but none of the others below it. As I moved them around in their order I realized that they were there, but falling behind the TextView on top. So, clearly, the issue is that they are layering instead of stacking.
Just to make sure we’re all on the same page in resolving this issue (which is really not an issue at all) we’re working on a layout XML file for an Android application. So if you’re using the built-in Eclipse Android plugin you will have a main.xml file by default in the res/layout directory. If you delete the XML from this file and add a new LinearLayout from the layout perspective, and then add some TextViews or whatever, you’ll notice that only the top one shows.
So for example.
Does not work
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:background="@android:color/black"> </LinearLayout>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:background="@android:color/black" android:orientation="vertical"> </LinearLayout>
For whatever reason, when you add a LinearLayout like this it does not include the ‘android:orientation=”vertical | horizontal”‘ attribute. Apparently this is a pretty important attribute. This determines if the assets stack horizontally or vertically. And if not specified no error is thrown, instead it just seems to layer, or possibly just show the top asset. Doesn’t really matter as far as I see it. For those of us who have no idea what we’re doing it should seriously throw an error or something.