title: Does /res/layout/main.xml describe a View or a ViewGroup?
body: <p>My <code>main.xml</code> looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
  &gt;
  &lt;TextView  
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/hello"
  /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Since the root element is a <code>LinearLayout</code>, which extends <code>ViewGroup</code>, why does <code>main.xml</code> get turned into a <code>View</code> instead of a <code>ViewGroup</code>? For example, in my main <code>Activity</code> class, I try to get the number of subviews that the <code>LinearLayout</code> contains like this:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      ViewGroup vg = (ViewGroup) findViewById(R.layout.main);
      Log.v("myTag", "num children: " + vg.getChildCount());
  </code></pre>
  
  <p>but it crashes when i call <code>vg.getChildCount()</code>.</p>
  
  <p>What is the right way of doing it?</p>